Skip to content

Instantly share code, notes, and snippets.

View mkint's full-sized avatar

Matt Kint mkint

  • California State University, Sacramento
  • Sacramento, California
View GitHub Profile
@arkival
arkival / javaTime.md
Last active February 20, 2018 02:44

Easy timestamps with java.time

Java 8 introduced the java.time package which makes short work of creating and parsing timestamps.

To create a String representation of a timestamp we can use LocalDateTime.now().toString(), e.g.

String ts = LocalDateTime.now().toString()

To convert the string back into a time object we can use the parse method of LocalDateTime, e.g.