Java SimpleDateFormat format Date to String as "2020.02.25.09.55.00"

Description

Java SimpleDateFormat format Date to String as "2020.02.25.09.55.00"

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

public class Main {

  static public void main(String[] args) {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
    String s = formatter.format(new Date());
    System.out.println(s);//from w ww.  ja va 2  s  . c  om
  }
}



PreviousNext

Related