Java Locale Format formatEn(T date, String pattern)

Here you can find the source of formatEn(T date, String pattern)

Description

format En

License

Apache License

Parameter

Parameter Description
date a parameter

Declaration

public static final <T extends Date> String formatEn(T 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.Locale;

public class Main {
    /**/*from  www  .ja v a 2s  . c  o  m*/
      * @param date
      * @param pattern: Date format pattern
      * @return
      */
    public static final <T extends Date> String formatEn(T date, String pattern) {
        if (date == null)
            return null;
        try {
            SimpleDateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
            String result = df.format(date);
            return result;
        } catch (Exception e) {
            return null;
        }
    }

    /**
      * @param date
      * @param pattern: Date format pattern
      * @return
      */
    public static final <T extends Date> String format(T date, String pattern) {
        if (date == null)
            return null;
        try {
            SimpleDateFormat df = new SimpleDateFormat(pattern);
            String result = df.format(date);
            return result;
        } catch (Exception e) {
            return null;
        }
    }
}

Related

  1. formatDouble(String pattern, double value)
  2. formatDoubleToCSV(double d)
  3. formatDuration(long nanoTime)
  4. formatedDate(Date date)
  5. formatElapsedTime(double runTime)
  6. formatFloat(float f, int numDecPlaces, boolean forceFractions)
  7. formatFloat(Float f, int style)
  8. formatFloat(float val)
  9. formatFraction2(final Number value)