Android Long to Date Convert parseTime(long time, String pattern)

Here you can find the source of parseTime(long time, String pattern)

Description

parse Time

Declaration

public static String parseTime(long time, String pattern) 

Method Source Code

//package com.java2s;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;

public class Main {
    public static String parseTime(long time, String pattern) {
        Date date = new Date(time);
        if (isBlank(pattern)) {
            pattern = "yyyy-MM-dd HH:mm";
        }/*ww w  . j av a2 s. c  o  m*/
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern,
                Locale.getDefault());
        return dateFormat.format(date);
    }

    public static boolean isBlank(String s) {
        if (s == null || "".equals(s.trim())) {
            return true;
        }
        return false;
    }
}

Related

  1. toJulianDayNumber(long epochMillis)
  2. toString(Long datetime)
  3. toTimeString(long milliseconds)
  4. stringForTime(long timeMs)
  5. getTimeString(long millis)
  6. getDateByInt(long va)
  7. getDateTimeString(long dateTime)
  8. getLabelForEventInTime(long inTime)
  9. getTimeDelta(long delta, String dateFormat)