Format date To String in yyyy-MM-dd HH:mm:ss format - Android java.util

Android examples for java.util:Date Format

Description

Format date To String in yyyy-MM-dd HH:mm:ss format

Demo Code

import android.util.Log;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Main{

    public static String dateToString(Date date) {
        SimpleDateFormat formater = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");
        return formater.format(date);
    }//from   w  w w  . j a v a2  s . co m

}

Related Tutorials