Skip to content

Instantly share code, notes, and snippets.

@LB--
Created February 7, 2015 01:58
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 LB--/3064de856857ad95753d to your computer and use it in GitHub Desktop.
Save LB--/3064de856857ad95753d to your computer and use it in GitHub Desktop.
Java 8 Time Library - just keeping this for reference
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.temporal.ChronoField;
class j8time
{
public static void main (String[] args) throws Throwable
{
//day before name changes
System.out.println(LocalDateTime.ofInstant(Instant.EPOCH, ZoneId.systemDefault())
.with(ChronoField.YEAR, 2015)
.with(ChronoField.MONTH_OF_YEAR, Month.FEBRUARY.getValue())
.with(ChronoField.DAY_OF_MONTH, 3)
.toInstant(ZoneOffset.UTC)
.toEpochMilli()/1000L);
//time I changed my name
System.out.println(Instant.ofEpochMilli(1423055984000L));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment