Answers for "java new local date time"

1

localdatetime java example

LocalDateTime current=LocalDateTime.now();//gets current LocalDateTime
LocalDateTime dateTime=LocalDateTime.of(year,month,day,hour,minute,second);//gets specific LocalDateTime
dateTime.getHour();//get the hour of a DateTime
dateTime.getDayOfWeek();//get number of current day in week
dateTime.isBefore(someOtherDateTime);//checks if it is before another LocalDateTime
dateTime.toLocalDate();//converts it to a LocalDate
dateTime.toLocalTime();//converts it to a LocalTime
Posted by: Guest on April-06-2021
-1

local date to date java

public LocalDate convertToLocalDateViaInstant(Date dateToConvert) {
    return dateToConvert.toInstant()
      .atZone(ZoneId.systemDefault())
      .toLocalDate();
}
Posted by: Guest on December-04-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language