Created
December 8, 2010 20:01
-
-
Save hlship/733810 to your computer and use it in GitHub Desktop.
Selection from DateField component that handles parsing the date string to the user's time zone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Regardless of the timeZone set on the DateFormat, the value is parsed in | |
// the current default TimeZone. Use the calendar to adjust it out. | |
Date inDefaultTimeZone = format.parse(value); | |
Calendar c = Calendar.getInstance(locale); | |
c.setTime(inDefaultTimeZone); | |
TimeZone clientZone = timeZoneTracker.getClientTimeZone(); | |
TimeZone defaultZone = TimeZone.getDefault(); | |
long now = System.currentTimeMillis(); | |
int offset = defaultZone.getOffset(now) - clientZone.getOffset(now); | |
c.add(Calendar.MILLISECOND, offset); | |
parsedValue = c.getTime(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment