how to get the from a date in java code example
Example 1: How to get current date and time in java
import java.util.Calendar;
import java.util.Date;
public class UsingCalendarClass
{
public static void main(String[] args)
{
Date date = Calendar.getInstance().getTime();
System.out.println(date);
}
}
Example 2: How to get current date and time in java
import java.time.LocalDateTime;
public class UsingLocalDateTime
{
public static void main(String[] args)
{
System.out.println(LocalDateTime.now());
}
}