Java SimpleDateFormat format Date to String as "Tue, 25 Feb 2020 09:54:21 -0800"

Description

Java SimpleDateFormat format Date to String as "Tue, 25 Feb 2020 09:54:21 -0800"

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

public class Main {

  static public void main(String[] args) {
    SimpleDateFormat formatter = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
    String s = formatter.format(new Date());
    System.out.println(s);//from   w  ww . j  a va  2 s  .co m
  }
}



PreviousNext

Related