Example usage for java.time LocalDateTime of

List of usage examples for java.time LocalDateTime of

Introduction

In this page you can find the example usage for java.time LocalDateTime of.

Prototype

public static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute) 

Source Link

Document

Obtains an instance of LocalDateTime from year, month, day, hour and minute, setting the second and nanosecond to zero.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01);

    LocalDateTime t = a.with(TemporalAdjusters.firstDayOfMonth());

    System.out.println(t);/*  www .j  a v  a  2 s .c o m*/
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);
    ZonedDateTime b = a.atZone(ZoneId.systemDefault());

    System.out.println(b);/*from   ww  w .  j  av  a  2s.co  m*/
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);

    OffsetDateTime b = a.atOffset(ZoneOffset.UTC);
    System.out.println(b);/*from w  w w  . j  a  va  2s  .c o  m*/
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);

    LocalTime t = a.query(TemporalQueries.localTime());

    System.out.println(t);//from   w  w w.  j a v a 2  s .  co m
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime dtPrevistaBR = LocalDateTime.of(2014, 3, 26, 10, 35);

    ZonedDateTime localOrigemZone = ZonedDateTime.of(dtPrevistaBR, ZoneId.systemDefault());

    ZoneId localEntregaZoneId = ZoneId.of("America/Bogota");
    ZonedDateTime dtPrevista = localOrigemZone.withZoneSameInstant(localEntregaZoneId);

    System.out.println("Data Prevista (Brasileira): " + dtPrevistaBR);
    System.out.println("Data Prevista (Bogota): " + dtPrevista.toLocalDateTime());
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime leaving = LocalDateTime.of(2013, Month.JULY, 20, 19, 30);

    ZoneId leavingZone = ZoneId.of("America/Los_Angeles");
    ZonedDateTime departure = ZonedDateTime.of(leaving, leavingZone);

    System.out.println(departure);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime ldt = LocalDateTime.of(2014, Month.JUNE, 21, 16, 30);

    ZoneId usCentral = ZoneId.of("America/Chicago");
    ZonedDateTime zdt = ZonedDateTime.of(ldt, usCentral);
    System.out.println("In US  Central Time Zone:" + zdt);

    ZoneId losAngeles = ZoneId.of("America/Los_Angeles");
    ZonedDateTime zdt2 = zdt.withZoneSameInstant(losAngeles);
    System.out.println("In  America/Los_Angeles Time Zone:" + zdt2);

}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime localDateTime = LocalDateTime.of(1982, Month.APRIL, 17, 14, 11);
    ZonedDateTime jakartaTime = ZonedDateTime.of(localDateTime, ZoneId.of("Asia/Jakarta"));
    System.out.println(jakartaTime); //1982-04-17T14:11+07:00[Asia/Jakarta]

    System.out.println(jakartaTime.withZoneSameInstant(ZoneId.of("America/Los_Angeles"))); //1982-04-16T23:11-08:00[America/Los_Angeles]
    System.out.println(jakartaTime.withZoneSameLocal(ZoneId.of("America/New_York"))); //1982-04-17T14:11-05:00[America/New_York]

}

From source file:Main.java

public static void main(String[] args) {
    // 2014-04-01 10:45
    LocalDateTime dateTime = LocalDateTime.of(2014, Month.APRIL, 1, 10, 45);

    // format as ISO week date (2014-W08-4)
    String asIsoWeekDate = dateTime.format(DateTimeFormatter.ISO_WEEK_DATE);

    System.out.println(asIsoWeekDate);
}

From source file:Main.java

public static void main(String[] args) {
    // 2014-04-01 10:45
    LocalDateTime dateTime = LocalDateTime.of(2014, Month.APRIL, 1, 10, 45);

    // format ISO date time (2014-02-20T20:04:05.867)
    String asIsoDateTime = dateTime.format(DateTimeFormatter.ISO_DATE_TIME);

    System.out.println(asIsoDateTime);
}