Java SimpleDateFormat format Date to String as "2020-02-25T11:07:54.793-08:00"

Description

Java SimpleDateFormat format Date to String as "2020-02-25T11:07:54.793-08:00"

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

  public static void main(String[] args) {

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
    String dateAsString = simpleDateFormat.format(new Date());
    System.out.println(dateAsString);

  }/*from   ww  w .  jav a2 s  . c  om*/

}



PreviousNext

Related