Java 8 – How to convert LocalTime to an Instant ?

In this article, we will learn how to convert LocalTime to an Instant by adding/combining date & zone informations using atDate(), atZone() & toInstant() methods provided in Java 1.8 version

For Instant to LocalTime conversion, read Java 8 – How to convert Instant to LocalTime ?

Convert LocalTime to an Instant :

Direct conversion between LocalTime and Instant isn’t possible hence convert LocalTime to LocalDateTime using atDate() method and then convert LocalDateTime to ZonedDateTime using atZone() method and then finally invoke toInstant() method to convert ZonedDateTime to an Instant

  • First, convert LocalTime to LocalDateTime using atDate() method –
    • atDate(LocalDate) – This method combines invoking LocalTime with a provided LocalDate to create a LocalDateTime
  • Second, convert LocalDateTime to an OffsetDateTime using atOffset() method –
    • atOffset(ZoneOffset) – This method combines invoking date-time with an offset to create an OffsetDateTime
  • Finally, convert ZonedDateTime to an Instant using toInstant() method –
    • toInstant() – This method converts invoking date-time to an Instant

package in.bench.resources.java8.localtime.examples;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;

public class ConvertLocalTimeToInstant {

	public static void main(String[] args) {

		// 1. get current system time
		LocalTime localTime =;
		System.out.println("Current system time is :- \n" 
				+ localTime);

		// 2. get current system date
		LocalDate localDate =;
		System.out.println("\nCurrent system date is :- \n" 
				+ localDate);

		// 3. get default time zone
		ZoneId zoneId = ZoneId.systemDefault();
		System.out.println("\nDefault time-zone is :- \n" 
				+ zoneId);

		// 4. convert LocalTime -> LocalDateTime -> ZonedDateTime -> Instant
		Instant instant = localTime // LocalTime
				.atDate(localDate) // LocalDateTime
				.atZone(zoneId) // ZonedDateTime
				.toInstant(); // Instant
		System.out.print("\nCurrent Instant at UTC/GMT is :- \n" 
				+ instant);


Current system time is :- 

Current system date is :- 

Default time-zone is :- 

Current Instant at UTC/GMT is :- 

Related Articles:


Happy Coding !!
Happy Learning !!

Java 8 – How to convert LocalTime to java.util.Date and vice-versa ?
Java 8 – How to convert LocalTime to an OffsetDateTime ?