Java 8 – Convert LocalDate to Instant
Below Java8 example shows you how to convert LocalDate to Instant.
Convert LocalDate to Instant
package com.sneppets.solution; import java.time.Instant; import java.time.LocalDate; import java.time.ZoneId; public class LocalDateToInstant { public static void main (String[] args) { LocalDate localDate = LocalDate.now(); System.out.println("LocalDate now() : " + localDate); //convert localdate to Instant Instant instant = localDate.atStartOfDay(ZoneId.systemDefault()).toInstant(); System.out.println("Instant : " + instant); } }
Output
LocalDate now() : 2019-11-28 Instant : 2019-11-27T18:30:00Z
Further Learning
- Use notepad++ XML Tools to edit XML files
- Build a Docker Image with a Dockerfile and Cloud Build in GCP
- Visualize Big Data using Google Data Studio
- Create Machine Learning model to predict online purchase conversion