Android Long to Date Convert convertNotNull(Long long1)

Here you can find the source of convertNotNull(Long long1)

Description

convert Not Null

Declaration

public static String convertNotNull(Long long1) 

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_AND_TIME_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
    public static String convertNotNull(String dateString) {
        if (StringUtils.isEmpty(dateString) || dateString.equals("0")) {
            return "null";
        }/*from   ww w . j a  v  a2 s. c  om*/
        Date date = parseDate(dateString);
        if (date == null) {
            return "null";
        } else {
            return String.valueOf(date.getTime());
        }
    }
    public static String convertNotNull(Long long1) {
        String str = String.valueOf(long1);
        if (StringUtils.isEmpty(str) || long1.equals("0")) {
            return "null";
        }
        Date date = parseDate(str);
        if (date == null) {
            return "null";
        } else {
            return String.valueOf(date.getTime());
        }
    }
    public static Date parseDate(String dateString) {
        SimpleDateFormat sdf = new SimpleDateFormat(
                FORMAT_DATE_AND_TIME_YYYY_MM_DD_HH_MM);
        try {
            return sdf.parse(dateString);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. GetDate(long milliseconds)
  2. convToEnglishTime(long dateMsec)
  3. converTime(long timestamp, String[] timeLabels)
  4. convertToDateStamp(long time)
  5. convertToTimeStamp(long time)
  6. convertToTimeStamp(long time, boolean showSeconds)
  7. dateFromUnixTimestamp(final long unixTimestamp)