List of usage examples for java.time LocalDateTime now
public static LocalDateTime now()
From source file:Main.java
public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); System.out.println(now.isSupported(ChronoField.YEAR)); System.out.println(now.isSupported(ChronoField.HOUR_OF_DAY)); System.out.println(ChronoField.YEAR.isSupportedBy(now)); System.out.println(ChronoField.HOUR_OF_DAY.isSupportedBy(now)); }
From source file:Main.java
public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); System.out.println(now.format(DateTimeFormatter.ofPattern("dd-MM-yy HH:mm:ss"))); }
From source file:Main.java
public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); System.out.println(now.get(ChronoField.YEAR)); System.out.println(now.get(ChronoField.MONTH_OF_YEAR)); System.out.println(now.get(ChronoField.DAY_OF_MONTH)); System.out.println(now.get(ChronoField.HOUR_OF_DAY)); System.out.println(now.get(ChronoField.HOUR_OF_AMPM)); System.out.println(now.get(ChronoField.AMPM_OF_DAY)); }
From source file:Main.java
public static void main(String[] args) { LocalDateTime timePoint = LocalDateTime.now(); LocalDateTime newDateTime = timePoint.plus(3, ChronoUnit.WEEKS).plus(3, ChronoUnit.YEARS); System.out.println(newDateTime); }
From source file:Main.java
public static void main(String[] args) { LocalDateTime currentDateTime = LocalDateTime.now(); System.out.println(currentDateTime); // 2014-06-27T09:04:47.527 // 2014-10-02 12:30 LocalDateTime secondAug2014 = LocalDateTime.of(2014, 10, 2, 12, 30); System.out.println(secondAug2014); // 2014-10-02T12:30 // 2014-12-24 12:00 LocalDateTime christmas2014 = LocalDateTime.of(2014, Month.DECEMBER, 24, 12, 0); System.out.println(christmas2014); // 2014-12-24T12:00 }
From source file:Main.java
public static void main(String[] argv) { long millisBetween = MILLIS.between(LocalDateTime.now(), LocalDateTime.now().plusMinutes(1)); System.out.println("millisBetween = " + millisBetween); }
From source file:Main.java
public static void main(String[] args) { OffsetDateTime o = OffsetDateTime.of(LocalDateTime.now(), ZoneOffset.UTC); System.out.println(o); }
From source file:Main.java
public static void main(String[] args) { System.out.println(timeZoneAdjustedDate(LocalDateTime.now())); }
From source file:Main.java
public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); Instant instant = now.atZone(ZoneId.systemDefault()).toInstant(); Date dateFromOld = Date.from(instant); System.out.println(dateFromOld); }
From source file:Main.java
public static void main(String[] args) { ZonedDateTime z = ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault()); System.out.println(z);//from w w w. java2s . c o m LocalDateTime timePoint = LocalDateTime.now(); ZoneId id = ZoneId.of("Europe/Paris"); ZonedDateTime zoned = ZonedDateTime.of(timePoint, id); System.out.println(zoned); }