Java Date Now getCurrentTime(String format)

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

Description

get Current Time

License

Open Source License

Declaration

public static String getCurrentTime(String format) 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public final static String FORMAT_DATE_TIME = "yyyy-MM-dd hh:mm";
    private static SimpleDateFormat sdf = new SimpleDateFormat();

    public static String getCurrentTime(String format) {
        if (format == null || format.trim().equals("")) {
            sdf.applyPattern(FORMAT_DATE_TIME);
        } else {/*from   www  .j a v a 2  s . c o  m*/
            sdf.applyPattern(format);
        }
        return sdf.format(new Date());
    }
}

Related

  1. getCurrentTime()
  2. getCurrentTime()
  3. getCurrentTime(Date _d)
  4. getCurrentTime(long delay, long interval)
  5. getCurrentTime(String format)
  6. getCurrentTime(String format)
  7. getCurrentTime(String format)
  8. getCurrentTime(String format)
  9. getCurrentTime(String formatter)