Android Date Format formatDate1(String date)

Here you can find the source of formatDate1(String date)

Description

format Date, "yyyy-MM-dd"

Declaration

public static String formatDate1(String date) 

Method Source Code

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;
    }
}

Related

  1. formatDate(Date date, String pattern, TimeZone zone)
  2. formatDate(Date time)
  3. formatDate(SimpleDateFormat s, Date d)
  4. formatDate(String date)
  5. formatDate(long millis)
  6. formatDateAndTime(long millis)
  7. formatTM(Date d)
  8. fromString(String dateStr)
  9. fromString(String dateStr, String dateFormat)