Skip to content

Instantly share code, notes, and snippets.

@benkn
Created April 20, 2016 13:23
Show Gist options
  • Save benkn/c7bc90291662d3d9b2ee7280590d3574 to your computer and use it in GitHub Desktop.
Save benkn/c7bc90291662d3d9b2ee7280590d3574 to your computer and use it in GitHub Desktop.
public final class DateOperations {
/**
* Gets the Epoch seconds of the given LocalDateTime
* @return long of the seconds since the beginning of time (for Java)
*/
public static long getLocalSeconds(LocalDateTime localDateTime) {
ZoneId zone = ZoneId.systemDefault();
ZonedDateTime zdt = localDateTime.atZone(zone);
return zdt.toEpochSecond();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment