Convert long To SQL Date yyyy-MM-dd HH:mm:ss Format - Android java.util

Android examples for java.util:Date Convert

Description

Convert long To SQL Date yyyy-MM-dd HH:mm:ss Format

Demo Code

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

public class Main{
    public final static String SQL_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static String longToSqlDateFormat(long date) {
        Date d = new Date(date);
        SimpleDateFormat dateFormat = new SimpleDateFormat(SQL_DATE_FORMAT);
        return dateFormat.format(d);
    }/*from w w  w . j ava2  s .c o  m*/

}

Related Tutorials