Java Date format to String like "24/02/2020"

Description

Java Date format to String like "24/02/2020"

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

public class Main {
  public static void main(String[] argv) {
    Date date = new Date();
    System.out.println(formatDate(date));
  }/*from   w  w  w.ja  v a  2 s  . c om*/

  public static final String formatDate(Date date) {
    return new SimpleDateFormat("dd/MM/yyyy").format(date);
  }
}



PreviousNext

Related