Java LocalDateTime toLocalDate() Method

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

Definition

In Java, dt.toLocalDate() returns a LocalDate with the year, month, and day of the date-time. The time of day is dropped.

The date-time itself does not change, because LocalDateTime is immutable. You get a new, smaller object.

An instance method of java.time.LocalDateTime (since Java 8): call it on a LocalDateTime object. Add import java.time.LocalDateTime; at the top of your file.

Syntax

Call it on a date-time. No arguments are needed.

Java
LocalDateTime dt = LocalDateTime.of(2026, 3, 15, 14, 30);

LocalDate date = dt.toLocalDate();   // 2026-03-15
CallWhat it does
dt.toLocalDate()The date part, as a LocalDate.
dt.toLocalTime()The time part, as a LocalTime.
date.atStartOfDay()Goes the other way: a date plus midnight.
date.atTime(time)A date plus a time you choose.

Use it when you only care about "which day", for example to group events or to check a birthday.

Library declarations
Java
// java.time.LocalDateTime
public LocalDate toLocalDate()

Parameters

ParameterDescription
NonetoLocalDate() takes no parameters.

Return Value

Return ValueDescription
LocalDateThe date part of this date-time. It is never null.

Compare with Similar Methods

Related methods:

MethodHow it differs
toLocalTime()The other half: the time of day.
truncatedTo(DAYS)Keeps a LocalDateTime but sets the time to midnight.
getDayOfMonth()Gets only the day number, as an int.

Java Examples

Example 1 — Get the Date Part of a Date-Time

Take the date from a date-time, and check that the original is not changed.

Java
import java.time.LocalDate;
import java.time.LocalDateTime;

public class LdtToLocalDateDemo {
    public static void main(String[] args) {
        LocalDateTime dt = LocalDateTime.of(2026, 3, 15, 14, 30, 45);

        LocalDate date = dt.toLocalDate();

        System.out.println("date:     " + date);
        System.out.println("day name: " + date.getDayOfWeek());
        System.out.println("original: " + dt);
    }
}

How It Works

  1. A date-time with a time. It is 15 March 2026 at 14:30:45.
  2. The date. toLocalDate() keeps the year, month, and day. The time is gone.
  3. LocalDate has its own methods. Here getDayOfWeek() shows that 15 March 2026 is a Sunday.
  4. The original is unchanged. The last line still shows the full date-time.

Example 2 — Count the Days in a List of Events

Convert each event to its date, and collect the dates in a TreeSet to count the different days.

Java
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

public class LdtToLocalDateGroup {
    public static void main(String[] args) {
        List<LocalDateTime> events = Arrays.asList(
            LocalDateTime.of(2026, 3, 15, 9, 0),
            LocalDateTime.of(2026, 3, 16, 11, 30),
            LocalDateTime.of(2026, 3, 15, 18, 45),
            LocalDateTime.of(2026, 3, 16, 8, 15),
            LocalDateTime.of(2026, 3, 20, 12, 0)
        );

        Set<LocalDate> days = new TreeSet<>();
        for (LocalDateTime event : events) {
            days.add(event.toLocalDate());
        }

        System.out.println("events: " + events.size());
        System.out.println("different days: " + days.size());
        System.out.println(days);
    }
}

How It Works

  1. Five events on three days. Some events share a day, but their times differ.
  2. Drop the time. toLocalDate() turns each event into a plain date.
  3. A set removes repeats. Equal dates are stored only once, so the five events leave three dates.
  4. A TreeSet sorts. The dates are printed in order, from the earliest to the latest.

Example 3 — Check If Two Date-Times Are on the Same Day

Compare a morning and an evening time, first as date-times, and then as dates.

Java
import java.time.LocalDateTime;

public class LdtToLocalDateSameDay {
    public static void main(String[] args) {
        LocalDateTime morning = LocalDateTime.of(2026, 3, 15, 8, 0);
        LocalDateTime evening = LocalDateTime.of(2026, 3, 15, 22, 0);
        LocalDateTime nextDay = LocalDateTime.of(2026, 3, 16, 0, 5);

        System.out.println("morning equals evening:  " + morning.equals(evening));
        System.out.println("same day (morning, evening): "
                + morning.toLocalDate().equals(evening.toLocalDate()));
        System.out.println("same day (evening, next):    "
                + evening.toLocalDate().equals(nextDay.toLocalDate()));
    }
}

How It Works

  1. Three date-times. Two are on 15 March, and one is five minutes after midnight on the 16th.
  2. As date-times they differ. The times are different, so equals prints false.
  3. As dates they match. Both dates are 15 March, so the second line prints true.
  4. A new day is a new date. Even a few minutes after midnight makes the date different, so the last line is false.

Frequently Asked Questions

Call dt.toLocalDate(). It returns a LocalDate with the year, month, and day.
Use dt.toLocalDate() to get a LocalDate, or dt.truncatedTo(ChronoUnit.DAYS) to keep a LocalDateTime at midnight.
No. LocalDateTime is immutable, so you get a new LocalDate and the original stays the same.
Compare their dates: a.toLocalDate().equals(b.toLocalDate()).
Use date.atStartOfDay() for midnight, or date.atTime(hour, minute) for a time you choose.

Next: toLocalTime()

Get only the time of day, without the date.

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

10 people found this page helpful