Java Now formatNow()

Here you can find the source of formatNow()

Description

format Now

License

Open Source License

Declaration

public static String formatNow() 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final String ISO_FORMAT_SECONDS = "yyyy-MM-dd'T'HH:mm:ss'Z'";
    private static final SimpleDateFormat isoFormat = new SimpleDateFormat();

    public static String formatNow() {
        return formatDateISO(new Date());
    }/*  w w w . j  av a 2s  .c  o m*/

    public static String formatDateISO(long millis) {
        Date d = new Date();
        d.setTime(millis);
        return formatDateISO(d);
    }

    public synchronized static String formatDateISO(Date date) {
        if (date == null) {
            return null;
        }
        isoFormat.applyPattern(ISO_FORMAT_SECONDS);
        return isoFormat.format(date);
    }
}

Related

  1. calNow()
  2. compareDateWithNow(Date date1)
  3. compareWithNow_2(String t)
  4. formatNow()
  5. formatNow()
  6. formatNow(String fmt)
  7. formatNow(String pattern)
  8. formatNow(String style)
  9. formatTime(Date now, String pattern)