get current time in yyyy-MM-dd format - Android java.util

Android examples for java.util:Date Format

Description

get current time in yyyy-MM-dd format

Demo Code

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

public class Main{


    public static String getData_yyyy_MM_dd() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date curDate = new Date(System.currentTimeMillis());
        String str = formatter.format(curDate);
        return str;
    }/*from w  ww .java2  s  .  com*/

}

Related Tutorials