get Current Date in yyyy-MM-dd format using SimpleDateFormat - Android java.util

Android examples for java.util:Date Format

Description

get Current Date in yyyy-MM-dd format using SimpleDateFormat

Demo Code

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

public class Main {

  public static final SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy-MM-dd");

  public static String getCurrentDate() {
    Date d = new Date(System.currentTimeMillis());
    return yearFormat.format(d);
  }/* www.jav a  2s . c  om*/

}

Related Tutorials