Obtaining the Current Date Without Time - Java Date Time

Java examples for Date Time:Local Date Time

Introduction

Use the Date-Time API to obtain the current date.

The LocalDate class represents an ISO calendar in the year-month-day format.

Demo Code

import java.text.DateFormatSymbols;
import java.time.Clock;
import java.time.LocalDate;
import java.util.Calendar;

public class Main {

    public static void main(String[] args) {

        LocalDate date = LocalDate.now();
        System.out.println("Current Date: " + date);

        Clock clock = Clock.systemUTC();
        date = LocalDate.now(clock);
        System.out.println("Date from clock: " + date);
    }//from   www.ja  va  2  s  .  c  om
}

Result


Related Tutorials