[ https://issues.apache.org/jira/browse/OFBIZ-5608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13979515#comment-13979515 ] Gareth Carter commented on OFBIZ-5608: -------------------------------------- Adrian The millisecond value does not reference a timezone, the millisecond value is the epoch value. However, java.util.Date will use the default java timezone to normalize the millisecond value to local time by applying an offset. Your testcase proves this but is irrelevant because java.sql.Date is not supposed to represent a specific instance in time like java.util.Date but simply an abstract date that does not change according to timezone, such as birthdate or christmas. People may celebrate christmas at different times but christmas day is always 25/12 of every year. When you use java.sql.Date, the time will always be set to midnight when using the deprecated constructors or static valueOf method in the local time. Again the milliseconds value will be different depending on default timezone but ultimately the value returned from toString() will be the same no matter the timezone. java.util.Date toString() displays the java default timezone whereas java.sql.Date does not. Why? There is no need if it only represents a date. When the java.sql.Date is formatted (using DateFormat) with a timezone that has a larger negative offset to the local time then the result will be the previous day. Basically any timezone west of current local time will display the previous day and any timezone east will not change the date (except for if local time is -12 and timezone applied was +12 or vice versa). This is very inconsitent behaviours. If the time was set to midday then other timezones will display correctly. I have also checked postgres, no matter which timezone I apply on the database, the sql date displays the same date. No matter what the default java timezone is the java.sql.Date will display correctly without applying another timezone. You have to ask yourself why is there no data type of date with timezone? SQL dates are fixed dates and because you cannot correctly apply a timezone to date without knowing a time! This seems to be the same for mysql and mssql if you read the documentation. It is at the point that ofbiz applies the user pref timezone to java.sql.Date that is causing this issue. I cannot see any flaws in fixing ofbiz to not apply a timezone to java.sql.Date only (how many sql date fields are there?). If we were not to apply a timezone to java.util.Date then I can see problems but you have to remember what each class represents. > Dates Displaying Incorrectly With Negative Offest Timezones. > ------------------------------------------------------------ > > Key: OFBIZ-5608 > URL: https://issues.apache.org/jira/browse/OFBIZ-5608 > Project: OFBiz > Issue Type: Bug > Components: ALL COMPONENTS > Affects Versions: SVN trunk, Release Branch 12.04, Release Branch 13.07 > Reporter: Rupert Howell > Priority: Minor > Fix For: SVN trunk > > Attachments: ObjectTypeTests.patch, dates.patch, dates_1589040.patch > > > Dates are displaying incorrectly when negative offset (relative to UTC) are applied by the users settings. -- This message was sent by Atlassian JIRA (v6.2#6252) |
Free forum by Nabble | Edit this page |