Java Date Now getCurrentTime()

Here you can find the source of getCurrentTime()

Description

get Current Time

License

Open Source License

Declaration

public static long getCurrentTime() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.Date;

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

    public static long getCurrentTime() {
        try {/*from  w  ww  .j a  v a  2  s. co m*/
            return new java.text.SimpleDateFormat(FMT_LONG_TIME).parse(getCurrentDate(FMT_LONG_TIME)).getTime()
                    / 1000;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0L;
    }

    public static String getCurrentDate(String fmt) {
        DateFormat d = new SimpleDateFormat(fmt);
        return d.format(new Date());
    }
}

Related

  1. getCurrentString(String pattern)
  2. getCurrentStringDate()
  3. getCurrentStringDate(String pattern)
  4. getCurrentStringDateYMD()
  5. getCurrentStrTimeMills()
  6. getCurrentTime()
  7. getCurrentTime()
  8. getCurrentTime()
  9. getCurrentTime()