Here you can find the source of formatDate1(String date)
public static String formatDate1(String date)
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import android.annotation.SuppressLint; public class Main{ private static final String FORMAT_DATE_YYYY_MM_DD = "yyyy-MM-dd"; public static String formatDate1(String date) { SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE_YYYY_MM_DD); String newKey;/* w ww .jav a2 s . c o m*/ if (StringUtils.isEmpty(date)) { newKey = ""; } else { newKey = date; } Date dt = new Date(Long.parseLong(newKey)); String sDateTime = null; sDateTime = sdf.format(dt); return sDateTime; } }