Skip to content

Instantly share code, notes, and snippets.

@sscovil
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sscovil/9642930 to your computer and use it in GitHub Desktop.
Save sscovil/9642930 to your computer and use it in GitHub Desktop.
public class DateTimeUtils {
public static final int SECONDS_IN_DAY = 86400;
public static long currentTimeInSecondsGMT() {
return System.currentTimeMillis()/1000;
}
public static long lastMidnightTimeInSecondsGMT() {
return (currentTimeInSecondsGMT() / SECONDS_IN_DAY) * SECONDS_IN_DAY;
}
public static long secondsSinceLastMidnightGMT() {
return currentTimeInSecondsGMT() % SECONDS_IN_DAY;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment