Java SimpleDateFormat format Date to String as "02/25/20"

Description

Java SimpleDateFormat format Date to String as "02/25/20"

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

public class Main {

  static public void main(String[] args) {
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yy");
    String s = formatter.format(new Date());
    System.out.println(s);/*from   w  ww.j a  va 2  s  . com*/
  }
}



PreviousNext

Related