Reputation: 79
Hi I have this method
public static Date toDate(XMLGregorianCalendar calendar)
if (calendar == null) {
return null;
}
return calendar.toGregorianCalendar().getTime();
}
The date I get from this method is with this format Fri May 30 12:00:00 EEST 2014
but I wan the format to be like dd-MM-yyyy HH:mm:ss
any idea how ??
Upvotes: 0
Views: 182
Reputation: 46841
Try with SimpleDateFormat to format the date object as per your need.
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
System.out.println(formatter.format(new Date()));
output:
11-06-2014 21:13:49
You are getting default toString()
implementation of Date
object.
Find the source code here Date#toString() that uses EEE MMM dd HH:mm:ss zzz yyyy
pattern.
Upvotes: 1