List of usage examples for java.time LocalDate of
public static LocalDate of(int year, int month, int dayOfMonth)
From source file:Main.java
public static void main(String[] args) { LocalDate date = LocalDate.of(2014, Month.JULY, 16); System.out.println(date);/*w w w . j a v a 2 s. c o m*/ LocalDate firstDayOfJuly = date.with(TemporalAdjusters.firstDayOfMonth()); // 2014-07-01 System.out.println(firstDayOfJuly); LocalDate dateOfFirstMonday = date.with(TemporalAdjusters.firstInMonth(DayOfWeek.MONDAY)); // 2014-07-07 System.out.println(dateOfFirstMonday); }
From source file:Main.java
public static void main(String[] argv) { LocalDate startEmployment = LocalDate.of(2010, Month.SEPTEMBER, 8); LocalDate today = LocalDate.now(); Period period = startEmployment.until(today); System.out.println("period = " + period); long numberOfDays = startEmployment.until(today, DAYS); System.out.println("numberOfDays = " + numberOfDays); }
From source file:Main.java
public static void main(String[] args) { Period p = Period.between(LocalDate.of(2009, Month.JANUARY, 21), LocalDate.of(2019, Month.JANUARY, 21)); System.out.println(p.get(ChronoUnit.DAYS)); LocalDate today = LocalDate.now(); LocalDate birthday = LocalDate.of(1960, Month.JANUARY, 1); LocalDate nextBDay = birthday.withYear(today.getYear()); nextBDay = nextBDay.plusYears(1);/*from ww w . ja va 2 s .com*/ p = Period.between(today, nextBDay); long p2 = ChronoUnit.DAYS.between(today, nextBDay); System.out.println(p.getMonths() + " months"); System.out.println(p.getDays() + " days"); }
From source file:Main.java
public static void main(String[] args) { LocalDate localDate = LocalDate.of(2014, Month.JUNE, 21); DayOfWeek dayOfWeek = DayOfWeek.from(localDate); System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, Locale.CANADA)); System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.CANADA)); System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, Locale.CANADA)); }
From source file:Main.java
public static void main(String[] args) { LocalDate date = LocalDate.of(2014, 2, 15); // 2014-02-15 // ISO-8601 standard // the day-of-week to represent, from 1 (Monday) to 7 (Sunday) DayOfWeek dayOfWeek = date.getDayOfWeek(); System.out.println(dayOfWeek); // SATURDAY System.out.println(DayOfWeek.of(3)); // WEDNESDAY System.out.println(dayOfWeek.getValue()); // 6 System.out.println(dayOfWeek.name()); // SATURDAY System.out.println(date.getDayOfMonth()); // 15 System.out.println(date.atStartOfDay()); // 2014-02-15 00:00 System.out.println("DayOfWeek"); dayOfWeek = DayOfWeek.FRIDAY; Locale locale = Locale.getDefault(); System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, locale)); // Friday System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, locale)); // F System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, locale)); // Fri }
From source file:Main.java
public static void main(String[] args) { LocalDate ld1 = LocalDate.of(2013, 12, 1); Boolean is = ld1.query(Main::queryFrom); System.out.println(is);//from w ww . j a v a2s . co m }
From source file:Main.java
public static void main(String[] args) { LocalDate date = LocalDate.of(2014, Month.FEBRUARY, 15); // 2014-02-15 DayOfWeek dayOfWeek = date.getDayOfWeek(); // SATURDAY dayOfWeek = DayOfWeek.FRIDAY; Locale locale = Locale.getDefault(); System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, locale)); // Friday System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, locale)); // F System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, locale)); // Fri }
From source file:Main.java
public static void main(String[] args) { int year = 2014; Month month = Month.JULY; int dayOfMonth = 14; LocalDate jugILThisYear = LocalDate.of(year, month, dayOfMonth); System.out.println(jugILThisYear); }
From source file:Main.java
public static void main(String[] args) { LocalDate ld = LocalDate.of(2014, Month.JUNE, 30); format(ld, "M/d/yyyy"); format(ld, "MM/dd/yyyy"); format(ld, "MMM dd, yyyy"); format(ld, "MMMM dd, yyyy"); format(ld, "EEEE, MMMM dd, yyyy"); format(ld, "'Month' q 'in' QQQ"); }
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); }