Reputation: 1732
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
Upvotes: 1
Views: 130
Reputation: 338574
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.
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.
Upvotes: 2