Java Time Now getNowAsNICSDate()

Here you can find the source of getNowAsNICSDate()

Description

get Now As NICS Date

License

Open Source License

Declaration

public static String getNowAsNICSDate() 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import org.joda.time.DateTime;

public class Main {
    public static String getNowAsNICSDate() {
        return getTimeFromMillisAsNICSDate(getNowAsMillis());
    }/* w ww .  ja va2s  .  c  om*/

    public static String getTimeFromMillisAsNICSDate(long timeInMillis) {
        SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
        return fmt.format(getDateFromMillis(timeInMillis));
    }

    public static long getNowAsMillis() {
        DateTime now = new DateTime();
        return now.getMillis();
    }

    public static Date getDateFromMillis(long millis) {
        Date date = null;
        try {
            DateTime dt = new DateTime(millis);
            date = dt.toDate();
        } catch (Exception e) {
        }
        return date;
    }
}

Related

  1. getNow()
  2. getNow()
  3. getNow(boolean ifdatetime)
  4. getNow(final String format)
  5. getNow(String format)
  6. getNowAsString()
  7. getNowDateTime()
  8. getNowDateTime()
  9. getNowDateTime()