get Current Date time in yy-MM-dd HH:mm:ss format - Android java.util

Android examples for java.util:Date Format

Description

get Current Date time in yy-MM-dd HH:mm:ss format

Demo Code

import android.annotation.SuppressLint;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Main{

    public static String getCurrentDatetime() {
        SimpleDateFormat df = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
        return df.format(new Date());
    }/*  ww  w  . jav a 2 s.c om*/

}

Related Tutorials