Java LocalDate Class | atStartOfDay() Method with Example

LocalDate Class atStartOfDay() method: Here, we are going to learn about the atStartOfDay() method of LocalDate Class with its syntax and example.
Submitted by Preeti Jain, on June 03, 2020

LocalDate Class atStartOfDay() method


public LocalDateTime atStartOfDay();
public ZonedDateTime atStartOfDay(ZoneId zo);
  • atStartOfDay() method is available in java.time package.
  • atStartOfDay() method is used to create a LocalDateTime at the start of this LocalDate by merging this date with the midnight time.
  • atStartOfDay(ZoneId zo) method is used to create a ZonedDateTime from this LocalDate object at the earliest valid time based on the rules in the given zone.
  • These methods don’t throw an exception at the time of returning the start of the day.
  • These are non-static methods and it is accessible with class objects and if we try to access these methods with the class name then we will get an error.


  • In the first cases, atStartOfDay(),
    • None
  • In the second cases, atStartOfDay(ZoneId zo),
    • ZoneId zo – represents the zone.

Return value:

In the first case, the return type of the method is LocalDateTime, it returns LocalDateTime that holds the value midnight time at the start of this LocalDate object.

In the second case, the return type of the method is ZonedDateTime, it returns ZonedDateTime that holds the value from this date at the earliest time in the given zone.


// Java program to demonstrate the example 
// of atStartOfDay() method of LocalDate

import java.time.*;

public class AtStartOfDayOfLocalDate {
    public static void main(String args[]) {
        // Instantiates two LocalDate
        LocalDate l_da1 = LocalDate.parse("2007-04-04");
        LocalDate l_da2 =;

        // Instantiates a zone for LocalDate l_da2
        ZoneId z_id = ZoneId.of("Africa/Accra");

        // Display l_da1,l_da2
        System.out.println("LocalDate l_da1 and l_da2: ");
        System.out.println("l_da1: " + l_da1);
        System.out.println("l_da2: " + l_da2);


        // Here, this method creates a LocalDateTime
        // by merging this date (l_da1) with 
        // the time of midnight at the start 
        // of this date l_da1
        LocalDateTime da_ti = l_da1.atStartOfDay();

        // Display da_ti
        System.out.println("l_da1.l_da1.atStartOfDay(): " + da_ti);

        // Here, this method creates a ZonedDateTime
        // from this date (l_da2) at the earliest
        // the valid time according to the rules
        // in the given time-zone (z_id) 
        ZonedDateTime zo_da_ti = l_da2.atStartOfDay(z_id);

        // Display zo_da_ti
        System.out.println("l_da2.atStartOfDay(z_id): " + zo_da_ti);


LocalDate l_da1 and l_da2: 
l_da1: 2007-04-04
l_da2: 2020-06-03

l_da1.l_da1.atStartOfDay(): 2007-04-04T00:00
l_da2.atStartOfDay(z_id): 2020-06-03T00:00Z[Africa/Accra]


Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.