List of usage examples for java.time LocalDate now
public static LocalDate now()
From source file:Main.java
public static void main(String[] argv) { String s = LocalDate.now().format(DateTimeFormatter.ISO_DATE); System.out.println(s); }
From source file:Main.java
public static void main(String[] args) { MonthDay m = MonthDay.from(LocalDate.now()); System.out.println(m); }
From source file:Main.java
public static void main(String[] args) { YearMonth y = YearMonth.from(LocalDate.now()); System.out.println(y); }
From source file:Main.java
public static void main(String[] argv) { LocalDate today = LocalDate.now(); System.out.println(String.format("Year : %s Month : %s day : %s", today.getYear(), today.getMonthValue(), today.getDayOfMonth()));/* w ww. j a v a 2 s.co m*/ LocalDateTime time = LocalDateTime.now(); System.out.println( String.format("Hour : %s Mins : %s Sec : %s", time.getHour(), time.getMinute(), time.getSecond())); }
From source file:Main.java
public static void main(String[] args) { LocalDate today = LocalDate.now(); // Get the Year, check if it's leap year System.out.println("Year " + today.getYear() + " is Leap Year? " + today.isLeapYear()); // Compare two LocalDate for before and after System.out.println("Today is before 01/01/2015? " + today.isBefore(LocalDate.of(2015, 1, 1))); // Create LocalDateTime from LocalDate System.out.println("Current Time=" + today.atTime(LocalTime.now())); }
From source file:Main.java
public static void main(String[] args) { LocalDate tomorrow = LocalDate.now().plusDays(1); // before 5 hours and 30 minutes LocalDateTime dateTime = LocalDateTime.now().minusHours(5).minusMinutes(30); System.out.println("additionSubtraction: tomorrow: " + tomorrow); System.out.println("additionSubtraction: dateTime: " + dateTime); }
From source file:Main.java
public static void main(String[] argv) { LocalDate dateOfBirth = LocalDate.now(); MonthDay birthday = MonthDay.of(dateOfBirth.getMonth(), dateOfBirth.getDayOfMonth()); MonthDay currentMonthDay = MonthDay.from(LocalDate.now()); if (currentMonthDay.equals(birthday)) { System.out.println("Yes!!"); } else {//from w w w.ja v a 2s. co m System.out.println("Sorry, today is not your birthday"); } }
From source file:Main.java
public static void main(String... args) { LocalDate today = LocalDate.now(); LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS); LocalDate yesterday = tomorrow.minusDays(2); System.out.println(today);/*from ww w . j a va 2 s. c o m*/ System.out.println(tomorrow); System.out.println(yesterday); }
From source file:Main.java
public static void main(String[] args) { System.out.println(convertToDatabaseColumn(LocalDate.now())); }
From source file:Main.java
public static void main(String[] argv) { LocalDate today = LocalDate.now(); LocalDate longestDay = today.with(Month.JUNE).withDayOfMonth(21); int p = Period.between(today, longestDay).getDays(); System.out.println(p);/*w ww. ja v a2s .c om*/ }