Android Date to String Convert getDateTimeString(Date date, int format, Locale currentLocale)

Here you can find the source of getDateTimeString(Date date, int format, Locale currentLocale)

Description

get Date Time String

Declaration

private static String getDateTimeString(Date date, int format,
            Locale currentLocale) 

Method Source Code

//package com.java2s;
import java.text.DateFormat;

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

public class Main {
    private static final Map<String, DateFormat> dateFormats = new HashMap<String, DateFormat>();

    private static String getDateTimeString(Date date, int format,
            Locale currentLocale) {

        String key = format + "_" + currentLocale.toString();

        DateFormat formatter = dateFormats.get(key);

        if (formatter == null) {
            formatter = DateFormat.getDateTimeInstance(format, format,
                    currentLocale);//from   ww  w .j a  va2  s .c o  m
            dateFormats.put(key, formatter);
        }

        return formatter.format(date);
    }
}

Related

  1. getCurrentDateStr()
  2. getCurrentDateStrs()
  3. getCurrentTimeStr()
  4. getDateByFormatedString(String date)
  5. getDateTimeString(Date date)
  6. getFileName()
  7. getFormatString(Date date, String dateFormat)
  8. getHourInFloat(Date date)
  9. getLongDateStr(Date date)