Java LocalDateTime ofInstant() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Java 8+

Definition

In Java, LocalDateTime.ofInstant(instant, zone) shows a moment in time (an Instant) as the wall-clock date and time of a ZoneId.

The Instant is the same everywhere in the world, but the clock on the wall depends on the zone. This method applies the zone rules, including daylight saving, and then drops the zone from the result.

A static method of java.time.LocalDateTime (since Java 8): call it on the class, as LocalDateTime.ofInstant(), with no object needed. Add import java.time.LocalDateTime; at the top of your file.

Syntax

Pass the moment and the zone.

Java
Instant moment = Instant.parse("2026-03-15T10:30:00Z");
LocalDateTime india = LocalDateTime.ofInstant(moment, ZoneId.of("Asia/Kolkata"));   // 2026-03-15T16:00
LocalDateTime tokyo = LocalDateTime.ofInstant(moment, ZoneId.of("Asia/Tokyo"));     // 2026-03-15T19:30
CallWhat it does
ofInstant(instant, zone)The wall-clock date and time of zone at that moment.
instant.atZone(zone)The same, but as a ZonedDateTime that keeps the zone.
dt.toInstant(offset)The reverse: a date-time plus an offset gives an Instant.
LocalDateTime.now(zone)The current moment in a zone.

ofInstant() is the right tool when you have a stored timestamp and want to display it in a user's zone.

Library declarations
Java
// java.time.LocalDateTime
public static LocalDateTime ofInstant(Instant instant, ZoneId zone)

Parameters

ParameterDescription
instant (Instant)The moment in time to convert.
zone (ZoneId)The zone whose clock to read, such as ZoneId.of("Asia/Tokyo") or ZoneOffset.UTC.

Return Value

Return ValueDescription
LocalDateTimeThe date and time shown by a clock in that zone at that moment.

Compare with Similar Methods

Ways to turn a moment into a LocalDateTime:

MethodHow it differs
ofEpochSecond(s, n, offset)Uses seconds and a fixed offset, with no daylight saving rules.
atZone(zone)The other direction: gives a ZonedDateTime from a local date-time.
now(zone)Reads the current moment in a zone.

Java Examples

Example 1 — Convert a UTC Moment to India Time

A server stores a UTC moment. Show it as the wall-clock time in India.

Java
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

public class LdtOfInstantDemo {
    public static void main(String[] args) {
        Instant moment = Instant.parse("2026-03-15T10:30:00Z");
        LocalDateTime india = LocalDateTime.ofInstant(moment, ZoneId.of("Asia/Kolkata"));

        System.out.println("moment: " + moment);
        System.out.println("India:  " + india);
    }
}

How It Works

  1. A UTC moment. The Z at the end of the text means UTC, and the moment prints with it.
  2. Pick a zone. ZoneId.of("Asia/Kolkata") is 5 hours 30 minutes ahead of UTC.
  3. The wall clock shows 16:00. 10:30 plus 5 hours 30 minutes is 16:00, on the same date.
  4. No zone in the result. The output has no Z or offset, because a LocalDateTime holds only date and time.

Example 2 — Show One Moment in Several Zones

Print the same moment as seen in India, Tokyo, and New York.

Java
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

public class LdtOfInstantZones {
    public static void main(String[] args) {
        Instant moment = Instant.parse("2026-03-15T10:30:00Z");
        String[] zones = {"Asia/Kolkata", "Asia/Tokyo", "America/New_York"};

        for (String zone : zones) {
            LocalDateTime local = LocalDateTime.ofInstant(moment, ZoneId.of(zone));
            System.out.println(zone + ": " + local);
        }
    }
}

How It Works

  1. One moment. All three results describe the same instant in time.
  2. India and Tokyo are ahead. They show 16:00 (UTC+5:30) and 19:30 (UTC+9).
  3. New York is behind. In mid-March the United States already uses daylight saving time, so New York is 4 hours behind UTC and shows 06:30.
  4. The zone rules are built in. You do not add hours yourself, so daylight saving is handled correctly.

Example 3 — See the Date Change with the Zone

Show the evening of 31 December in UTC as seen in Tokyo and in Los Angeles.

Java
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

public class LdtOfInstantDate {
    public static void main(String[] args) {
        Instant newYearsEve = Instant.parse("2026-12-31T20:00:00Z");

        LocalDateTime tokyo = LocalDateTime.ofInstant(newYearsEve, ZoneId.of("Asia/Tokyo"));
        LocalDateTime losAngeles = LocalDateTime.ofInstant(newYearsEve, ZoneId.of("America/Los_Angeles"));

        System.out.println("Tokyo:       " + tokyo);
        System.out.println("Los Angeles: " + losAngeles);
    }
}

How It Works

  1. 20:00 UTC on 31 December. This is one moment, but the calendar can show a different date elsewhere.
  2. Tokyo is 9 hours ahead. The clock passes midnight, so it already shows 5 o'clock in the morning of 1 January 2027.
  3. Los Angeles is 8 hours behind in winter. The clock shows noon, still on 31 December 2026.
  4. The year differs too. One moment can be in two different years, depending on the zone.

Frequently Asked Questions

Use LocalDateTime.ofInstant(instant, ZoneId.systemDefault()) for the computer's zone, or give a specific ZoneId.
Call LocalDateTime.ofInstant(instant, zone). The zone decides which wall-clock time you get.
ofInstant uses a ZoneId with daylight saving rules. ofEpochSecond uses a fixed ZoneOffset and a raw number of seconds.
No. A LocalDateTime has no zone. Use instant.atZone(zone) to keep it in a ZonedDateTime.
Yes. It was added in Java 8 together with the rest of java.time.

Next: parse()

Read a date-time from text.

parse() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful