This content has been marked as final. Show 5 replies
Can't say I'm sure why you would see that kind of behaviour.
You could rewrite the code using SimpleDateFormat (why you're using regular expressions is beyond my understanding) and see whether the same behaviour continues.
That seems to be a very complex approach to parsing a date. Surely it could be done much simpler using SimpleDateFormat.
A java.util.Date object does not contain an explicit format or time zone; there is an implicit time zone of UTC but this takes no part in the output of the toString() and the java.util.Date.toString() method will print in the default time zone. You don't say how the Date is formatted prior to printing but my best guess is that you are relying this toString() method and therefore on the default time zone and somebody has changed it to UTC.
When printing dates and numbers for presentation to users ALWAYS use an explicit formatter configured with the desired Locale and Timezone.
thank you guys for the reply. This is not our application. it is a 3rd party library that we use. I guess we probably should override it
Also posted here:
and here - http://www.coderanch.com/t/595305/java/java/java-date-timezone-odd-behavior