Android Long to Date Convert millToDate(Long mill)

Here you can find the source of millToDate(Long mill)

Description

mill To Date

License

Open Source License

Declaration

public static String millToDate(Long mill) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static String millToDate(String mill) {
        Long date = Long.valueOf(mill);
        SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = new Date(date);
        return sfd.format(date1);
    }/* w w  w .  java  2 s.com*/

    public static String millToDate(Long mill) {
        SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date1 = new Date(mill);
        return sfd.format(date1);
    }

    public static String format(String str, Object... args) {
        if (isEmptyOrNull(str))
            return "";
        if (args.length == 0)
            return str;
        String result = str;
        Pattern p = java.util.regex.Pattern.compile("\\{(\\d+)\\}");
        Matcher m = p.matcher(str);
        while (m.find()) {
            int index = Integer.parseInt(m.group(1));
            if (index < args.length) {
                result = result.replace(m.group(), args[index].toString());
            }
        }
        return result;
    }

    public static boolean isEmptyOrNull(String str) {
        return str == null || str.length() == 0
                || str.contentEquals("null") || str.trim().equals("");
    }
}

Related

  1. getLongFriendlyDate(long timeInMillis)
  2. getShortFriendlyDate(long timeInMillis)
  3. getTimeStringFrom(long timestamp)
  4. humanFriendlyDate(long time)
  5. longToDate(long timestamp)
  6. toDateFromTimestamp(long date)
  7. transMillionToTime(long milliseconds)
  8. transformDateTime(long t)
  9. millis2cal(long milliseconds, boolean clearTime)