Format Calendar to string in yyyy-MM-dd kk:mm.ss format - Android java.util

Android examples for java.util:Calendar

Description

Format Calendar to string in yyyy-MM-dd kk:mm.ss format

Demo Code

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

public class Main{

     private static SimpleDateFormat dateFormatSql = new SimpleDateFormat(
            "yyyy-MM-dd kk:mm.ss");
    public static String dateToSqlStr(Calendar date) {
        return dateFormatSql.format(date.getTime());
    }/*from  ww  w.ja v a2  s .  c  om*/

}

Related Tutorials