Java Long Number to Date formatDate(long millis)

Here you can find the source of formatDate(long millis)

Description

Format date for QuakeML

License

Creative Commons License

Parameter

Parameter Description
millis milliseconds since 1/1/1970 00:00:00 GMT

Return

time string in yyyy-MM-dd'T'HH:mm:ss.SSSX format

Declaration

public static String formatDate(long millis) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSX";

    /**/*from   ww  w . j a  v a 2  s  .c o m*/
     * Format date for QuakeML
     * 
     * @param millis milliseconds since 1/1/1970 00:00:00 GMT
     * @return time string in yyyy-MM-dd'T'HH:mm:ss.SSSX format
     */
    public static String formatDate(long millis) {
        SimpleDateFormat dateF = new SimpleDateFormat(DATE_FORMAT);
        dateF.setTimeZone(TimeZone.getTimeZone("UTC"));
        Date date = new Date(millis);
        return dateF.format(date);
    }
}

Related

  1. formatDate(Long date, String fmt)
  2. formatDate(long date, String format)
  3. formatDate(long date, String langStr)
  4. formatDate(long dateValue)
  5. formatDate(long epochMillis)
  6. formatDate(long millis)
  7. formatDate(long millis)
  8. formatDate(long millis, Locale locale)
  9. formatDate(long millis, String dateFormat)