Java Date Now getCurrentTime()

Here you can find the source of getCurrentTime()

Description

get Current Time

License

Apache License

Declaration

public static String getCurrentTime() 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String FORMAT1 = "yyyy-MM-dd HH:mm:ss";
    public static final String FORMAT5 = "HH:mm:ss";

    public static String getCurrentTime() {
        return getCurrentDateTime(FORMAT5);
    }/*from   w w  w . j a v  a 2  s . c  o  m*/

    public static String getCurrentDateTime() {
        return getCurrentDateTime(FORMAT1);
    }

    public static String getCurrentDateTime(String format) {
        SimpleDateFormat df = new SimpleDateFormat(format);
        return df.format(new Date());
    }
}

Related

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