Minimum to know about dates and time in Java
Please avoid coding the following method. It has no effect and demonstrates a lack of understanding of Date and Calendar.
// BULLSHIT CODE! This method does nothing. public static Date convertTz(Date date, TimeZone tz) { Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("UTC")); cal.setTime(date); cal.setTimeZone(tz); return cal.getTime(); }
Odi has a great explanation of the bare minimums you need to understand about dates and times to make useful, real world applications. The examples concern Java, but similar concerns must be taken in other languages as well. Highly recommended reading.
Comments (0)
Trackbacks (1)
Leave a comment
Trackback
-
April 9, 2011 at 6:39 pmDatetimes in Python – gotchas and workarounds « Developmentality