Android examples for java.util:Date Format
Format Date in yyyy-MM-dd HH:mm:ss
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.regex.Pattern; public class Main{ private final static SimpleDateFormat dateFormater = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss", Locale.CHINA); public static String convertTimeStumpToDate(String time) { try {/* w w w . j a v a 2 s. c o m*/ return dateFormater.format(new Date(toLong(time) * 1000L)); } catch (Exception e) { return null; } } public static long toLong(String obj) { try { return Long.parseLong(obj); } catch (Exception e) { } return 0; } }