Java LocalDateTime now() Method

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

Definition

In Java, LocalDateTime.now() returns a LocalDateTime that holds the current date and the current time, read from the system clock in the computer's default time zone.

The result has no zone attached: it is only the date and the clock time you would see on a wall clock. There are two other versions, now(ZoneId) and now(Clock), that let you pick the zone or the clock.

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

Syntax

Call the static method on the class. No new is needed.

Java
LocalDateTime a = LocalDateTime.now();                          // system default zone
LocalDateTime b = LocalDateTime.now(ZoneId.of("Asia/Tokyo"));    // a chosen zone
LocalDateTime c = LocalDateTime.now(Clock.systemUTC());          // a chosen clock
CallWhat it does
LocalDateTime.now()The current date and time in the default time zone.
LocalDateTime.now(zone)The current date and time in the given ZoneId.
LocalDateTime.now(clock)The date and time that a Clock reports. Use a fixed clock in tests.
LocalDate.now()Only the date, without the time.

The value is different every time you run the program, so the examples on this page print facts about it instead of the value itself.

Library declarations
Java
// java.time.LocalDateTime
public static LocalDateTime now()
public static LocalDateTime now(ZoneId zone)
public static LocalDateTime now(Clock clock)

Parameters

ParameterDescription
Nonenow() takes no parameters.
zone (ZoneId)Optional. The time zone to read the time in, such as ZoneId.of("Asia/Tokyo").
clock (Clock)Optional. The clock to read from. Clock.fixed() always returns the same moment.

Return Value

Return ValueDescription
LocalDateTimeThe current date and time, without any zone information.

Compare with Similar Methods

Other ways to get a LocalDateTime:

MethodHow it differs
of(...)Builds a date-time from numbers you choose.
parse(text)Reads a date-time from text.
ofInstant(instant, zone)Converts a moment in time into the local date-time of a zone.

Java Examples

Example 1 — Check What now() Gives You

The value of now() changes every run, so print facts about it that are always the same.

Java
import java.time.LocalDateTime;

public class LdtNowDemo {
    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime start2020 = LocalDateTime.of(2020, 1, 1, 0, 0);

        System.out.println("now is after 2020:  " + now.isAfter(start2020));
        System.out.println("year is 2020 or more: " + (now.getYear() >= 2020));
        System.out.println("hour is 0 to 23:    " + (now.getHour() >= 0 && now.getHour() <= 23));
    }
}

How It Works

  1. Read the clock. LocalDateTime.now() stores the current date and time in now.
  2. Why not print it? The real value changes every run, so this example checks facts that are always true.
  3. After a fixed date. The current moment is later than 1 January 2020, so isAfter prints true.
  4. Parts have valid ranges. The year is at least 2020 and the hour is always between 0 and 23, so the other two lines print true as well.

Example 2 — Use a Fixed Clock for Predictable Results

Create a clock that always reports the same moment, then read it in UTC and in India.

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

public class LdtNowClock {
    public static void main(String[] args) {
        Instant moment = Instant.parse("2026-03-15T10:30:00Z");

        Clock utcClock = Clock.fixed(moment, ZoneOffset.UTC);
        Clock indiaClock = Clock.fixed(moment, ZoneId.of("Asia/Kolkata"));

        System.out.println("UTC:   " + LocalDateTime.now(utcClock));
        System.out.println("India: " + LocalDateTime.now(indiaClock));
    }
}

How It Works

  1. One fixed moment. Instant.parse reads 10:30 UTC on 15 March 2026.
  2. Two fixed clocks. Clock.fixed(moment, zone) always reports that moment, as seen from the given zone.
  3. UTC. now(utcClock) shows 10:30.
  4. India. India is 5 hours 30 minutes ahead of UTC, so the same moment shows as 16:00. The output never changes, which makes tests easy.

Example 3 — Read the Time in Another Zone

Read the time in UTC and in Tokyo and print how many hours apart they are.

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

public class LdtNowZone {
    public static void main(String[] args) {
        LocalDateTime utc = LocalDateTime.now(ZoneId.of("UTC"));
        LocalDateTime tokyo = LocalDateTime.now(ZoneId.of("Asia/Tokyo"));

        long hours = Duration.between(utc, tokyo).toHours();
        System.out.println("Tokyo is ahead of UTC by " + hours + " hours");
    }
}

How It Works

  1. Two zones. now(ZoneId) reads the current moment and shows it as the wall-clock time of that zone.
  2. Different clock times. The two values have the same date-time only if the zones match, which they do not.
  3. Measure the gap. Duration.between(utc, tokyo) gives the difference, and toHours() turns it into whole hours.
  4. Tokyo is UTC+9. The tiny time between the two calls is lost when the duration is cut to whole hours, so the answer is 9.

Frequently Asked Questions

Use LocalDateTime.now(). For only the date use LocalDate.now(), and for only the time use LocalTime.now().
Use LocalDateTime.now(ZoneId.of("Asia/Tokyo")), or ZonedDateTime.now(zone) if you also want the zone kept in the result.
Pass a Clock into your code and call LocalDateTime.now(clock). In tests use Clock.fixed(...) so the time never changes.
No. It only stores the date and the clock time. Use ZonedDateTime.now() or OffsetDateTime.now() if you need the zone or offset.
It uses the default time zone of the machine. Pass an explicit ZoneId, or set the server to UTC, to get the same result everywhere.

Next: of()

Build a date-time from the year, month, day, hour, and minute.

of() 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.

12 people found this page helpful