List of usage examples for java.time LocalTime of
public static LocalTime of(int hour, int minute, int second, int nanoOfSecond)
From source file:Main.java
public static void main(String[] args) { LocalTime l = LocalTime.of(12, 23, 34, 123123); System.out.println(l); }
From source file:Main.java
public static void main(String[] args) { LocalTime time = LocalTime.of(15, 30, 23, 234); // 15:30:00 System.out.println(time.getHour()); // 15 System.out.println(time.getMinute()); // 30 System.out.println(time.getSecond()); // 23 System.out.println(time.getNano()); // 234 System.out.println(time.toSecondOfDay()); // 55823 System.out.println(time.toNanoOfDay()); // 55823000000234 }
From source file:Main.java
public static void main(String[] args) { LocalDate localDate = LocalDate.of(2013, 11, 12); LocalTime localTime = LocalTime.of(23, 10, 44, 12882); ZoneId chicago = ZoneId.of("America/Chicago"); ZonedDateTime chicagoTime = ZonedDateTime.of(localDate, localTime, chicago); System.out.println(chicagoTime); }
From source file:Main.java
public static void main(String[] args) { LocalTime lt = LocalTime.of(16, 30, 5, 78899); format(lt, "HH:mm:ss"); format(lt, "KK:mm:ss a"); format(lt, "[MM-dd-yyyy][' at' HH:mm:ss]"); ZoneId usCentral = ZoneId.of("America/Chicago"); ZonedDateTime zdt = ZonedDateTime.of(LocalDate.now(), lt, usCentral); format(zdt, "MM/dd/yyyy HH:mm:ssXXX"); format(zdt, "MM/dd/yyyy VV"); format(zdt, "[MM-dd-yyyy][' at' HH:mm:ss]"); }
From source file:Main.java
public static void main(String[] args) { LocalDate february20th = LocalDate.of(2014, Month.FEBRUARY, 20); System.out.println(february20th); System.out.println(LocalDate.from(february20th.plus(15, ChronoUnit.YEARS))); // 2029-02-20 System.out.println(LocalDate.MAX); System.out.println(LocalDate.MIN); System.out.println(LocalTime.MIDNIGHT); // 00:00 System.out.println(LocalTime.NOON); // 12:00 System.out.println(LocalTime.of(23, 12, 30, 500)); // 23:12:30.000000500 System.out.println(LocalTime.now()); // 00:40:34.110 System.out.println(LocalTime.ofSecondOfDay(11 * 60 * 60)); // 11:00 System.out.println(LocalTime.from(LocalTime.MIDNIGHT.plusHours(4))); // 04:00 System.out.println(LocalTime.MIN); System.out.println(LocalTime.MAX); System.out.println(LocalDateTime.of(2014, 2, 15, 12, 30, 50, 200)); // 2014-02-15T12:30:50.000000200 System.out.println(LocalDateTime.now()); // 2014-02-28T17:28:21.002 System.out.println(LocalDateTime.from(LocalDateTime.of(2014, 2, 15, 12, 30, 40, 500).plusHours(19))); // 2014-02-16T07:30:40.000000500 System.out.println(LocalDateTime.MAX); }
From source file:org.dozer.converters.LocalTimeConverter.java
@Override public Object convert(Class destClass, Object srcObj) { LocalTime convertedValue = null; try {/*from ww w . j a v a 2 s.com*/ if (srcObj instanceof String) { convertedValue = LocalTime.parse((String) srcObj); } else { LocalTime srcObject = (LocalTime) srcObj; convertedValue = LocalTime.of(srcObject.getHour(), srcObject.getMinute(), srcObject.getSecond(), srcObject.getNano()); } } catch (Exception e) { MappingUtils.throwMappingException("Cannot convert [" + srcObj + "] to LocalTime.", e); } return convertedValue; }