Consider the following code:
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy", Locale.US); long start = sdf.parse("10:30:00 30/09/2009").getTime(); long end = sdf.parse("10:30:00 30/10/2009").getTime(); Calendar c = Calendar.getInstance(Locale.US); c.setTimeInMillis(start); System.out.println("Start = " + c.getTime()); c.setTimeInMillis(end); System.out.println(" End = " + c.getTime());
When I run this piece of code, I have the following output:
Start = Wed Sep 30 10:30:00 CEST 2009 End = Fri Oct 30 10:30:00 CET 2009
Why am I getting a different time zone?
Please note that if I set the first date in August and the second in September, the output will display the same time zone in both cases:
long start = sdf.parse("10:30:00 30/08/2009").getTime(); long end = sdf.parse("10:30:00 30/09/2009").getTime();
will display:
Start = Sun Aug 30 10:30:00 CEST 2009 End = Wed Sep 30 10:30:00 CEST 2009
I am using Java 1.6.0_14
java date calendar simpledateformat
romaintaz
source share