Java - LocalDate

Java Conceptuel Diagram

Java - LocalDate

About

javase/9/docs/api/java/time/LocalDate.html - A date in the ISO-8601 calendar system, such as 2007-12-03

  • without a time-zone
  • without the time part (only YYYY-MM-DD) (ie with day precision)

Management

Init

in the default time zone

LocalDate localDate = LocalDate.of(year,month,day);
LocalDate localDate = LocalDate.parse("2009-01-01",DateTimeFormatter.ISO_DATE);
LocalDate localDate = LocalDate.now();

Print

sout(localDate.format(DateTimeFormatter.ISO_DATE));

Between

  • Number of days between two local date
import static java.time.temporal.ChronoUnit.DAYS;
DAYS.between(from,to)

Format

With javase/9/docs/api/java/time/format/DateTimeFormatter.html. Note this is a datetime otherwise

LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HHmm"))

note:

  • HH will always output 2 digits whereas H will only output one digit (same for (m and mm)
  • ppH outputs the hour-of-day padded on the left with spaces to a width of 2.





Discover More
Java Conceptuel Diagram
Java - Calendar

The java/util/Calendarjava.util.Calendar is a class that wraps a instant in time and offers utility function that manipulate time. The java/util/Calendarjava.util.Calendar class provides: a...
Java Conceptuel Diagram
Java - Date

A Date is a java object that wraps time information. java/util/Date - The class Date represents a specific instant in time, with millisecond precision. It's an instant on the time-line, not a “date”....
Java Conceptuel Diagram
Java - Time

Java.time package supplants the old java.util.Date/Calendar classes. java/time/package-summaryjava.time since JDK1.8. It contains the main API based on the ISO-8601 standard. See 310Date and Time Api...



Share this page:
Follow us:
Task Runner