Java Hour Format formatDate(Date date, String format, Locale locale)

Here you can find the source of formatDate(Date date, String format, Locale locale)

Description

format Date

License

LGPL

Declaration

public static String formatDate(Date date, String format, Locale locale) 

Method Source Code

//package com.java2s;
/*//from w w w .  ja v  a  2  s  .c  o  m
* Distributable under LGPL v3 license.
* See terms of license at https://github.com/Yunfeng/schotel/blob/master/LICENSE
*/

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Locale;

public class Main {
    public static String formatDate(Date date, String format, Locale locale) {
        SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
        return sdf.format(date);
    }

    public static String formatDate(Date date, String format) {
        if (format == null)
            format = "yyyy-MM-dd HH:mm:ss";
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
}

Related

  1. formatDate(Date date, String format)
  2. formatDate(Date date, String format)
  3. formatDate(Date date, String format)
  4. formatDate(Date date, String format)
  5. formatDate(Date date, String format)
  6. formatDate(Date date, String patter)
  7. formatDate(Date date, String pattern)
  8. formatDate(Date date, String pattern)
  9. formatDate(Date date, String timeFormat, String timeZone)