Java Date to String dateToString(Date date, String formatStr)

Here you can find the source of dateToString(Date date, String formatStr)

Description

dateToString.

License

Open Source License

Parameter

Parameter Description
date date
formatStr formatStr

Return

String

Declaration

public static String dateToString(Date date, String formatStr) 

Method Source Code

//package com.java2s;

import java.text.*;
import java.util.*;

public class Main {
    /**//from w w  w . j  a v a  2s .  co  m
     * dateToString.
     * @param date date
     * @param formatStr formatStr
     * @return String
     */
    public static String dateToString(Date date, String formatStr) {
        DateFormat format = new SimpleDateFormat(formatStr);
        return format.format(date);
    }

    /**
     * format.
     * @param input input
     * @param replace replace
     * @return String
     */
    public static String format(String input, String... replace) {
        String str = "";
        Formatter formatter = new Formatter();
        try {
            str = formatter.format(input, (Object[]) replace).toString();
        } finally {
            formatter.close();
        }
        return str;
    }
}

Related

  1. dateToString(Date date, String format)
  2. dateToString(Date date, String format)
  3. dateToString(Date date, String format)
  4. dateToString(Date date, String format)
  5. dateToString(Date date, String format)
  6. DateToString(Date date, String parttern)
  7. dateToString(Date date, String pattern)
  8. DateToString(Date date, String pattern)
  9. dateToString(Date date, String pattern)