Created
October 1, 2010 21:38
-
-
Save koush/606905 to your computer and use it in GitHub Desktop.
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
public static GregorianCalendar getSynchronizedTime() { | |
// this time zone is the local time zone | |
GregorianCalendar greg = new GregorianCalendar(); | |
// find the offset from GMT and adjust accordingly. | |
// server is in GMT | |
int offset = greg.getTimeZone().getOffset(greg.getTimeInMillis()); | |
greg.add(GregorianCalendar.MILLISECOND, -offset); | |
return greg; | |
} | |
public static String generateTimestamp() | |
{ | |
SimpleDateFormat dateFormatter = new SimpleDateFormat( | |
"yyyy-MM-dd'T'HH:mm:ss'Z'"); | |
GregorianCalendar greg = getSynchronizedTime(); | |
return dateFormatter.format(greg.getTime()); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment