Java SimpleDateFormat format Date to String as "25-Feb-20"

Description

Java SimpleDateFormat format Date to String as "25-Feb-20"

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

public class Main {

  static public void main(String[] args) {
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yy");
    String s = formatter.format(new Date());
    System.out.println(s);// w  w  w . ja  va  2s . c  o m
  }
}



PreviousNext

Related