DateFormat.parse( String s ) != DateFormat.format( Date d )
Hi,
I want to parse a string, using a particular DateFormat, into a Date. I then try to format this date into a String. But this simple reverse function produces different results.
Here is my code:
publicstaticvoid main(String[] args)
{
try
{
ISO8601DateFormat df =new ISO8601DateFormat();
String s1 ="1981-04-06T13:52:30.441GMT";
Date creationDate = df.parse( s1 );
String s2 = df.format( creationDate );
System.out.println("s1: " + s1 );
System.out.println("s2: " + s2 );
}catch( ParseException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
which produces the following results:
s1: 1981-04-06T13:52:30.441GMT
s2: 1981-04-06T14:52:30.441IST
Any ideas why this is?
The ISO8601DateFormat class is as follows:
publicclass ISO8601DateFormatextends SimpleDateFormat
{
public ISO8601DateFormat()
{
super("yyyy-MM-dd'T'HH:mm:ss.SSSz" );
}
}

