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

Android examples for java.util:Date Format

Description

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

Demo Code

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

public class Main{
    private static final String SDF_FORMAT = "dd-MM-yyyy HH:mm:ss";
    public static String dateToString(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat(SDF_FORMAT);
        return sdf.format(date);
    }//w  ww  . ja v  a 2s .c o m

}

Related Tutorials