Example usage for java.time LocalDate of

List of usage examples for java.time LocalDate of

Introduction

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

Prototype

public static LocalDate of(int year, int month, int dayOfMonth) 

Source Link

Document

Obtains an instance of LocalDate from a year, month and day.

Usage

From source file:Main.java

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

    System.out.println(a.isSupported(ChronoField.DAY_OF_YEAR));
}

From source file:Main.java

public static void main(String[] args) {

    LocalDate firstDate = LocalDate.of(2013, 5, 17);
    LocalDate secondDate = LocalDate.of(2015, 3, 7);
    Period period = Period.between(firstDate, secondDate);

    System.out.println(period);/* w  ww.ja  v a 2  s .c  om*/
}

From source file:Main.java

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

    long p = a.until(LocalDate.of(2015, 6, 30), ChronoUnit.MONTHS);

    System.out.println(p);/*  www  . ja va  2s .  co  m*/
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);
    LocalDate b = a.query(TemporalQueries.localDate());
    System.out.println(b);//from  www.j av a  2  s  . c  o m
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, 6, 21);
    int year = localDate.getYear();
    System.out.println(year);//from w  ww  . ja v  a  2s.  c  o m
    Month month = localDate.getMonth();
    System.out.println(month);

    int day = localDate.getDayOfMonth();
    System.out.println(day);

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate localDate1 = LocalDate.of(2014, Month.MAY, 2);
    System.out.println(localDate1);

    LocalDate localDate2 = localDate1.withYear(2015);
    System.out.println(localDate2);

    LocalDate localDate3 = localDate1.withYear(2014).withMonth(7);
    System.out.println(localDate3);

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);
    LocalDate b = a.with(TemporalAdjusters.firstDayOfMonth());
    System.out.println(b);/* w w  w .  j  av a  2 s  . c o  m*/
}

From source file:Main.java

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

    String s = a.format(DateTimeFormatter.BASIC_ISO_DATE);

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

From source file:Main.java

public static void main(String[] args) {
    LocalDate date = LocalDate.of(2014, 2, 15); // 2014-02-15
    Month february = date.getMonth();
    System.out.println(february); // FEBRUARY

    int februaryIntValue = february.getValue();
    System.out.println(februaryIntValue); // 2

    // 28 , 29//w  ww.j a va2  s  .  c o  m
    System.out.println(String.format("%s , %s", february.minLength(), february.maxLength()));

    Month firstMonthOfQuarter = february.firstMonthOfQuarter();
    System.out.println(firstMonthOfQuarter); // JANUARY
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate localDate1 = LocalDate.of(2014, 5, 21);
    System.out.println(localDate1);

    LocalDate localDate2 = LocalDate.of(2014, Month.MARCH, 4);
    System.out.println(localDate2);

    LocalDate localDate3 = LocalDate.ofEpochDay(2014);
    System.out.println(localDate3);

    LocalDate localDate4 = LocalDate.ofYearDay(2014, 39);
    System.out.println(localDate4);
}