Member-only story

How will you get the current date and time using Java8 Date and Time API ?

--

Java 8 Date Time API to get current date and time.

package com.demo.main;

public class GetCurrentDateAndTime {

public static void main(String[] args) {
// LocalDate API to get the current Date
System.out.println("Current Date : "+java.time.LocalDate.now());

// LocalTime API to get the current Time

System.out.println("Current Time : "+java.time.LocalTime.now());

// LocalDateTime to get current Date and Time.

System.out.println("Current Date And Time : "+java.time.LocalDateTime.now());
}
}

Watch Video Here :

--

--

Gain Java Knowledge
Gain Java Knowledge

Written by Gain Java Knowledge

The Java programming language is one of the most popular languages today. Stay up to date with news, certifications, free learning resources and much more.

No responses yet