This content has been marked as final. Show 2 replies
Please note that "DST", "Timezone" and stuff like that are display issues only. java.util.Date doesn't know about any of it.
A java.util.Date object represents a 'moment in time', represented as the number of milliseconds since the moment in time we western humans call January 1st, 1970, 0:00:00,000.
As 2:00 AM and 3:00 AM on a DST-switch date represent the exact same moment in time, there is no way for a java.util.Date to know about the distinction.
So if you want to display the distinction for the benefit of the user (I wonder why, but that's your problem), you will have to look outside java.util.Date for a solution. Depending on how your database stores its values, you might be able to retrieve the String representation of the date and work with that.
TBH, I would look at fixing the inconsistencies in the database instead of creating work-arounds for them in your code. But then I don't know your problem domain, perhaps you have a very good reason for having two different representations of the same moment in time.
You are right.
Thats the business requirement of our scenario. We have tried some, to fix this issue are;
1. Geting the date from the database as a String. (This requires major changes in the existing code. i.e. change all the beans that use the date object)
2. Disabling the DST for that particular moment to retrieve the date and enabling it back.
3. Store the date as UTC in the database. [This can't be done since we are refering some historical data].
Just explaining you about our status. We are looking forward to fix this issue by generating a wrapper class which can be implemented in all the places where we are refering to the date with the Date object.
Keep posted if you found any solution for this.
Message was edited by: