Java Date Now getCurrentTimeInString(String format)

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

Description

get Current Time In String

License

Open Source License

Parameter

Parameter Description
format a parameter

Return

String Current time in String.

Declaration

public static String getCurrentTimeInString(String format) 

Method Source Code

//package com.java2s;

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

public class Main {
    /**/*from w  w  w .  j av  a 2  s  .c  om*/
     * @param format
     * @return String
     *          Current time in String.
     */
    public static String getCurrentTimeInString(String format) {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.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. getCurrentTimeForName()
  2. getCurrentTimeForUseInAFileName()
  3. getCurrentTimeInMySqlTime()
  4. getCurrentTimeInMySqlTime()
  5. getCurrentTimeInString(SimpleDateFormat dateFormat)
  6. getCurrentTimeNoHour()
  7. getCurrentTimeNumber()
  8. getCurrentTimeOfDay()
  9. getCurrentTimeStamp()