Skip to content

Instantly share code, notes, and snippets.

@bigtoast
Created August 16, 2011 22:12
Show Gist options
  • Save bigtoast/1150325 to your computer and use it in GitHub Desktop.
Save bigtoast/1150325 to your computer and use it in GitHub Desktop.
dates with jodatime datetime
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