get current time in yyyy-MM-dd HH:mm:ss format - Android java.util

Android examples for java.util:Date Format

Description

get current time in yyyy-MM-dd HH:mm:ss format

Demo Code

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

public class Main{

    public static String getData_yyyy_MM_dd_hh_mm_ss() {
        SimpleDateFormat formatter = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");
        Date curDate = new Date(System.currentTimeMillis());
        String str = formatter.format(curDate);
        LogUtil.Log(tag, "getData_yyyy_MM_dd_hh_mm_ss = " + str);
        return str;
    }/*from   w w w  . j  av  a 2  s.  c o  m*/

}

Related Tutorials