Java Now now()

Here you can find the source of now()

Description

now

License

Open Source License

Parameter

Parameter Description
f a parameter
format a parameter

Declaration

public static String now() 

Method Source Code


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

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    private static final String DEFAULT_TSFORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";

    /**// w  ww. j a v  a 2  s .  c om
     * @param f
     * @param format
     * @return
     */
    public static String now() {
        return now(DEFAULT_TSFORMAT);
    }

    public static String now(String format) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(System.currentTimeMillis());
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(cal.getTime());
    }
}

Related

  1. getTimeNowAsString(String pattern)
  2. getTimeSubFromNowTime(String time)
  3. getValidDate(String unknownDate)
  4. isNowInInterval(String start, String end)
  5. makeUniqueName(final String[] knownNames, final String pattern)
  6. now()
  7. now()
  8. now()
  9. now()