Java Millisecond Format formatMillis(String millisecond, String format)

Here you can find the source of formatMillis(String millisecond, String format)

Description

format Millis

License

Open Source License

Declaration

public static String formatMillis(String millisecond, String format) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {

    public static String formatMillis(String millisecond, String format) {
        Date date;/*from   w w  w .  j  av  a  2 s .  c o m*/
        if (format == null || "".equals(format)) {
            format = "yyyy-MM-dd HH:mm:ss";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        if (millisecond != null && millisecond.matches("\\d+")) {
            date = new Date(Long.parseLong(millisecond));
            return sdf.format(date);
        }
        return "";
    }
}

Related

  1. formatMillis(long millis)
  2. formatMillis(long t)
  3. formatMillis(long time)
  4. formatMillis(long time, boolean showMillis)
  5. formatMillis(long timeMillis)
  6. formatMillisAsNumber(long millis)
  7. formatMillisAsShortHumanReadablePeriod(long millis)
  8. formatMilliseconds (final long ms)
  9. formatMilliseconds(Double milliseconds)