0
how to display current date and time in java
complete codes if there is someone who got them please....
2 Respuestas
+ 3
Here's are some of the ways to get current time or date , forgive me if I missed to include other ways.
import java.util.*;
import java.time.LocalDate;
public class Program
{
    public static void main(String[] args) {
        //calender instance
        Date date1 = Calendar.getInstance().getTime();
        
        //util date
        Date date2 = new Date();
        
        //sql date
        java.sql.Date sqlDate= new java.sql.Date(date2.getTime());
        
        //from java 8
        LocalDate local = LocalDate.now();
      
      System.out.println(date1);
      System.out.println(date2);
      System.out.println(sqlDate);
      System.out.println(local);
      
    }
}
0
Thanks I really appreciate



