The output is d1 = Sun Sep 09 07:16:40 GMT+05:30 2001 9/9/01 parsed = Sun Sep 09 00:00:00 GMT+05:30 2001
K&B says Notice that because we were using a SHORT style, we lost some precision when we converted the Date to a String. This loss of precision showed up when we converted back to a Date object, and it went from being 7:46 to midnight.
I changes the style to DateFormat.LONG or even MEDIUM,FULL still gets the same output.Still there is a precision loss?
getDateInstance returns a formatter that will only format the date and not the time. So changing the style has no effect on the time part since it is ignored.
Joined: Nov 01, 2006
David, This means that the description in the K&B book is not proper.It is showing the reason as "since the formater is using DateFormat.SHORT so there will be a precision loss." What should we do in order to format the time also? [ January 03, 2007: Message edited by: Sanjeev Kumar Singh ]
Joined: Oct 30, 2006
I agree with you, it looks like K & B has an error. Anyhow if you want to get a date time format use:
You can find 3 overridden versions of this method in the API documentation.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com