Answers for "date and time in java"

22

java how to get current date

import java.time.format.DateTimeFormatter;  
import java.time.LocalDateTime;    
public class CurrentDateTimeExample1 {    
  public static void main(String[] args) {    
   DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");  
   LocalDateTime now = LocalDateTime.now();  
   System.out.println(dtf.format(now));  
  }    
}
Posted by: Guest on June-10-2020
4

How to get current date and time in java

// get current date and timein java using Calendar.getTime() method
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);
   }
}
Posted by: Guest on November-30-2020
13

java date time

import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;  
public class CurrentDateTimeExample1 {  
  public static void main(String[] args) {  
   DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
   LocalDateTime now = LocalDateTime.now();
   System.out.println(dtf.format(now));
  }  
}
Posted by: Guest on June-03-2020
1

what is T in the date in java

The T is just a literal to separate the date from the time, and the Z means "zero hour offset" also known as "Zulu time" (UTC). If your strings always have a "Z" you can use: SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss. SSS'Z'", Locale.US); format. setTimeZone(TimeZone.07-Dec-2011
Posted by: Guest on June-07-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language