P E N C I L
Login
Date Time

Java8 Time



https://docs.oracle.com/javase/tutorial/datetime/iso/format.html

Parse

DateTimeFormatter VALIDITY_FORMATTTER = DateTimeFormatter.ofPattern("yyyyMMdd HHmmss")
LocalDate.parse(validity, VALIDITY_FORMATTTER)

ZoneID

ZoneOffset.UTCZoneId.of(ZoneId.SHORT_IDS.get("PST")

LocalDate

LocalDate.of(year,month,day)

LocalDate.now()

LocalDate.atStartOfDay() => midnight

LocaleDateTime

LocaleDateTime.of(localdate, localTime)

LocalDateTime.of(instant)

LocaleDateTime.atZone(ZoneId.systemDefault()).toInstant().

LocaleDateTime.toInstant(ZoneOffset.UTC);

LocaleTime.MIDNIGHT

ZonedDateTime ~ Instant

ZonedDateTime.ofInstant(instant, ZoneOffset.UTC)

ZonedDateTime.toInstant()

ZonedDateTime.truncatedTo(ChronoUnit.DAYS) DAYS=

Instant

Instant.now()

Instant.toEpochMillis()

ZoneOffset extends ZoneId

ZoneOffset.UTC

Joda



boolean isToday = dateTime.toLocalDate().equals(new LocalDate());

return formatter.print(dateTime);



Convert

DateTime dateTime = new DateTime(date);

Threade safe:

Joda DateTimeFormat is thread-safe

Format:

DateTimeFormat is thread-safe

DateTimeFormat.forStyle("SM).withLocale(Locale.French).print(d)

=> "20/10/2017 13:26:42"