Java Date Format Pattern getFormat(long stamp, String pattern)

Here you can find the source of getFormat(long stamp, String pattern)

Description

Get the dateFormat from given timestamp in milliseconds and the pattern

License

Open Source License

Parameter

Parameter Description
stamp The timestamp (System.currentTimeMillis())
pattern The pattern (e.g.: 'dd.MM.yyyy HH:mm:ss.SSS')

Return

The format as string

Declaration

public static String getFormat(long stamp, String pattern) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**//from ww w.  j  av  a2  s.  com
     * Get the dateFormat from given timestamp in milliseconds and the pattern
     *
     * @param stamp   The timestamp (System.currentTimeMillis())
     * @param pattern The pattern (e.g.: 'dd.MM.yyyy HH:mm:ss.SSS')
     * @return The format as string
     */
    public static String getFormat(long stamp, String pattern) {
        return new SimpleDateFormat(pattern).format(new Date(stamp));
    }

    public static String getFormat(long stamp) {
        return getFormat(stamp, "dd.MM.yyyy HH:mm:ss.SSS");
    }
}

Related

  1. getExcelFormat()
  2. getFolderFormat()
  3. getFormat()
  4. getFormat()
  5. getFormat(long stamp)
  6. getFormat(String format)
  7. getFormat(String formatPattern)
  8. getFormat(String formatString)
  9. getFormat(String pattern)