Created
August 16, 2011 22:12
-
-
Save bigtoast/1150325 to your computer and use it in GitHub Desktop.
dates with jodatime datetime
This file contains hidden or 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
var org_date_created; | |
var org_date_of_sale; | |
// zones ( local is for dev environments | |
local = org.joda.time.DateTimeZone.getDefault(); | |
cenZone = org.joda.time.DateTimeZone.forID('America/Chicago'); | |
// dates from db in central | |
dc = (new org.joda.time.DateTime( date_created )).withZoneRetainFields(cenZone); | |
dos = (new org.joda.time.DateTime( date_of_sale )).withZoneRetainFields(cenZone); | |
// org zone | |
tz = org.joda.time.DateTimeZone.forID( trim( time_zone ) ); | |
// convert to org zone then convert to local keeping the orgs time values ( no time conversion ) | |
org_date_created = dc.withZone( tz ).withZoneRetainFields( local ).toDate(); | |
org_date_of_sale = dos.withZone( tz ).withZoneRetainFields( local ).toDate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment