Created
June 29, 2017 08:37
-
-
Save fluency03/bf9d6f6cd596ccb63bb8e4ea40ca1b4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.time.LocalDateTime; | |
| import java.time.LocalTime; | |
| import java.time.LocalDate; | |
| import java.time.ZoneId; | |
| import java.time.ZonedDateTime; | |
| import static java.time.Month.*; | |
| import java.time.Clock; | |
| public class TestLocalTime { | |
| public static void main(String[] args) { | |
| System.out.println(LocalTime.of(9, 22)); | |
| System.out.println(LocalTime.of(9, 22, 43)); | |
| System.out.println(LocalTime.of(9, 22, 43, 99)); | |
| System.out.println(LocalTime.of(9, 22, 43, 9900)); | |
| System.out.println(LocalTime.of(9, 22, 43, 9900000)); | |
| System.out.println(LocalTime.now()); | |
| System.out.println("----"); | |
| ZoneId ny = ZoneId.of("America/New_York"); | |
| ZoneId ams = ZoneId.of("Europe/Amsterdam"); | |
| LocalDate date = LocalDate.of(2014, MARCH, 23); | |
| LocalTime time = LocalTime.of(9, 30); | |
| LocalDateTime localTime = LocalDateTime.of(date, time); | |
| ZonedDateTime nyTime = ZonedDateTime.of(date, time, ny); | |
| ZonedDateTime amsTime = ZonedDateTime.of(date, time, ams); | |
| System.out.println("localTime: " + localTime); | |
| System.out.println("nyTime: " + nyTime); | |
| System.out.println("amsTime: " + amsTime); | |
| System.out.println(ZonedDateTime.now()); | |
| System.out.println(Clock.systemDefaultZone()); | |
| System.out.println(ZoneId.systemDefault()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment