Skip to content
Home » Java Programs » Get Current Date and Time in Java

Get Current Date and Time in Java

Basic get current date and time in java. Although Java lacks a built-in Date class, we may deal with the date and time API by importing the java.time package. Many dates and time lessons are included in the bundle.

LocalDateTime in Java

LocalDateTime is an immutable date-time object that represents a date in the year-month-day-hour-minute-second format. Day-of-year, day-of-week, and week-of-year are among the other date and time parameters that can be retrieved. Nanosecond precision is used to express time. get current date and time in java for beginners to understand the programming in java.

Display Current Date and Time

The Date class in Java is found in the java. util package and includes a number of methods for working with dates and times. The Cloneable, Serializable, and Comparable interfaces of Java are implemented by the Date class. Using this get current date and time in java programming.

A Java package is a collection of classes, interfaces, and sub-packages that are similar in nature. In Java, packages are divided into two types: built-in packages and user-defined packages. Many built-in packages are available, including java, lang, awt, javax, swing, net, io, util, sql, and so on.

Package in Java

A package is a namespace that groups together classes and interfaces that are related. The Java platform has a large class library (a collection of packages) that you may use to create your own apps. The “Application Programming Interface,” or “API,” is the name given to this library. 

Get Current Date and Time in Java

import java.time.LocalDateTime;
public class Main 
public static void main(String[] args) 
LocalDateTime current =;
System.out.println("Date and Time" + current);


Date and Time 2015-09-29 T 10:26:01.205979