Java Hour Format format(String pattern)

Here you can find the source of format(String pattern)

Description

Formats actual date with specified pattern.

License

Open Source License

Parameter

Parameter Description
pattern a parameter

Declaration

public static String format(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 {
    /**// w w w . ja  va 2s.co m
     * Formats given date with specified pattern.
     * @param pattern
     * @param date
     * @return 
     */
    public static String format(String pattern, Date date) {
        return new SimpleDateFormat(pattern).format(date);
    }

    /**
     * Formats actual date with specified pattern. Usage DateHelper.format("HH:mm:ss")
     * @param pattern
     * @return 
     */
    public static String format(String pattern) {
        return format(pattern, new Date());
    }
}

Related

  1. format(List list, int scale)
  2. format(long time)
  3. format(long time)
  4. format(Number price)
  5. format(String format, Date val)
  6. format(String str)
  7. format16ByDate(Date aDate)
  8. format1StringToformat2String(String dateStr)
  9. format2NormalTime(Date date)