Java Date Now getCurrentTime(String pattern)

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

Description

Get current time for pattern.

License

Open Source License

Declaration

public static String getCurrentTime(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 {
    /**/*from   www . j a  v  a 2 s .  co  m*/
     * Get current time for pattern.
     * 
     * @return
     */
    public static String getCurrentTime(String pattern) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
        return dateFormat.format(new Date());
    }

    /**
     * Get current time for pattern.
     * 
     * @return
     */
    public static Date getCurrentTime() {
        return new Date();
    }
}

Related

  1. getCurrentTime(String format)
  2. getCurrentTime(String formatter)
  3. getCurrentTime(String pattern)
  4. getCurrentTime(String pattern)
  5. getCurrentTime(String pattern)
  6. getCurrentTime(String timeFormat)
  7. getCurrentTime2MysqlDateTime()
  8. getCurrentTimeAndDate()
  9. getCurrentTimeAsNumber()