1

if I execute this code:

String data = "08/02/1941";
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = dateFormat.parse(data);

I have in output the date: Sat Feb 08 01:00:00 CEST 1941

instead if I execute this code:

String data = "08/02/1971";
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = dateFormat.parse(data);

the date is: Sat Feb 08 01:00:00 CET 1971.

Why do I have this difference (CET and CEST)?

My timezone is Europe/Berlin (UTC+1) and I'm using Java 1.7.0_67-b01

2
  • You have 1941 being reported in both outputs. Commented Nov 13, 2014 at 17:06
  • FYI, the terribly troublesome old date-time classes such as java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat are now legacy, supplanted by the java.time classes built into Java 8 and later. See Tutorial by Oracle. Commented Sep 4, 2018 at 4:50

1 Answer 1

2

War Time — Shifting Time Zones

Daylight Saving Time was observed all year long in 1941 in Berlin. Known by some as "Hitler Time" according to this history of DST in Europe.

The times zones of Europe shifted around dramatically during and after the war. For example, this post (supposedly from Royal Observatory of Greenwich) describes some of these shifts including "Double" DST. These shifts are interesting cases of time zones playing a significant role in history. At least one academic uses the term "chronopolitics" for such phenomenon.

Date-only

If you want to represent a date without a time-of-day and without a time zone, use the LocalDate classe.

LocalDate ld = LocalDate.of( 1941 , Month.FEBRUARY , 8 ) ;

ld.toString(): 1941-02-08

The time zone issues discussed above drop away.

Sign up to request clarification or add additional context in comments.

4 Comments

Not holding, just a summary heading like I use on many of my answers. Relevant as this is an interesting case where a time zone played a role in history. Try reading the history as I am at this moment.
+1 for historical correctness where political correctness fails.
After reading more history, turns out that the year-round DST of 1941 was not a one-off event by Hitler. Rather, all kinds of crazy time zone changes were a part of the war and even the post-war period. So, I changed the heading to emphasize the bigger picture. And make a pun of "war time".
@BasilBourque thank you also for historial explanation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.