Java Millisecond Format formateTime(long milliseconds)

Here you can find the source of formateTime(long milliseconds)

Description

formate Time

License

Apache License

Declaration

public static String formateTime(long milliseconds) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public final static String TIMEFORMAT_WITHOUT_SECONDS = "yyyy/M/d HH:mm";

    public static String formateTime(long milliseconds) {
        SimpleDateFormat formatter = new SimpleDateFormat(TIMEFORMAT_WITHOUT_SECONDS);
        Date date = new Date(milliseconds);
        formatter.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        return formatter.format(date);
    }//from   w w w .j  a va2s . c o  m

    public static String formateTime(long milliseconds, String timeFormat) {
        SimpleDateFormat formatter = new SimpleDateFormat(timeFormat);
        Date date = new Date(milliseconds);
        formatter.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        String time = formatter.format(date);
        return time;
    }
}

Related

  1. format_duration(long millis)
  2. formatCcsdsUtcMillisFormat(Date time)
  3. formatDataTimeStamp(final long timeInMillis)
  4. formatElapsedMillis(long time)
  5. formatElapsedTime(long millis)
  6. formatMillis(int millis, int digits)
  7. formatMillis(long duration)
  8. formatMillis(long millis)
  9. formatMillis(long millis)