Hi,

I'm unable to change the date format in java. I'm given the code as follow.

java.util.Date date = new Date();

But it displays like july 17 13:01:43 GT 51:25 2010
But i need only this format july 17 13:01:43 2010
Can u pls help on this?

Your code given complete date,time and everything. it is a default format.
The below code is exactly reach your requirement

java.util.Date date = new java.util.Date();
DateF=" " + java.text.DateFormat.getDateTimeInstance().format(dateFormat);

And the second approach is you can change your format by ur self

java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd");
java.util.Date date = new java.util.Date();
DateF=dateFormat.format(date);

Thanks boss. Now it is working fine for me. You solved my problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.