We would like to know how to convert "machine time" to human units.
import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; /*w w w . ja v a 2s . c o m*/ public class Main { public static void main(String[] args) { // Instant is useful for generating a time stamp to represent machine time. Instant timestamp = Instant.now(); // Convert "machine time" to human units LocalDateTime humanTime = LocalDateTime.ofInstant(timestamp, ZoneId.systemDefault()); System.out.println(humanTime); } }
The code above generates the following result.