Posted In: Date, Java Core

Convert java.util.Date to java.time.LocalDate, LocalDateTime


Date date1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
		.parse("2017-08-13 12:10:30");

LocalDate localdate = date1.toInstant().atZone(ZoneId.systemDefault())
		.toLocalDate();

LocalDateTime localdatetime = date1.toInstant().atZone(ZoneId.systemDefault())
		.toLocalDateTime();

by , on August 24th, 2017

  • Categories