Java Time Format getFormatTimeString(Date date, String pattern)

Here you can find the source of getFormatTimeString(Date date, String pattern)

Description

get Format Time String

License

Apache License

Declaration

public static String getFormatTimeString(Date date, String pattern) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Main {
    private static Map<String, SimpleDateFormat> formats = new HashMap();

    public static String getFormatTimeString(Date date, String pattern) {
        SimpleDateFormat sDateFormat = getDateFormat(pattern);

        synchronized (sDateFormat) {
            return sDateFormat.format(date);
        }/*from   ww w.  j a v a 2  s.c o m*/
    }

    public static SimpleDateFormat getDateFormat(String pattern) {
        SimpleDateFormat sDateFormat = (SimpleDateFormat) formats.get(pattern);
        if (sDateFormat == null) {
            sDateFormat = new SimpleDateFormat(pattern);
            formats.put(pattern, sDateFormat);
        }
        return sDateFormat;
    }
}

Related

  1. getFormattedTime(final Date date)
  2. getFormattedTimeFilesafe(long t)
  3. getFormattedTimeString(double s)
  4. getFormatTime(Date date)
  5. getFormatTime(String format)
  6. getFullDateTimeFormat()
  7. getFullTime(String format, Date date)
  8. getGenerationTime(String format)
  9. getIntegerDateTime(Date date, String dateFormat)