A date without a time-zone in the ISO-8601 calendar system, such as 2017-12-03.
LocalDate is an immutable date-time object that represents a date, often viewed as year-month-day.
Other date fields, such as day-of-year, day-of-week and week-of-year, can also be accessed.
For example, the value "2nd October 2017" can be stored in a LocalDate.
A time without a time-zone in the ISO-8601 calendar system, such as 10:15:30.
LocalTime is an immutable date-time object that represents a time, often viewed as hour-minute-second.
Time is represented to nanosecond precision.
For example, the value "13:45.30.123456789" can be stored in a LocalTime.
A date-time without a time-zone in the ISO-8601 calendar system, such as 2017-12-03T10:15:30.
LocalDateTime is an immutable date-time object that represents a date-time, often viewed as year-month-day-hour-minute-second.
Other date and time fields, such as day-of-year, day-of-week and week-of-year, can also be accessed.
Time is represented to nanosecond precision.
For example, the value "2nd October 2017 at 13:45.30.123456789" can be stored in a LocalDateTime.
/** * @author lautturi.com * Java example: android get current local date and time in java */ import java.util.*; import java.text.SimpleDateFormat; import java.time.*; public class Lautturi { public static void main(String[] args) { LocalDate curDate = LocalDate.now(); LocalTime curTime = LocalTime.now(); LocalDateTime curDatetime = LocalDateTime.now(); System.out.println("Current Date:"+curDate); System.out.println("Current Time:"+curTime); System.out.println("Current Date and Time:"+curDatetime); } }
output:
Current Date:2020-11-03 Current Time:05:56:30.031418100 Current Date and Time:2020-11-03T05:56:30.031418100