Java Date Now getNowDate(String format)

Here you can find the source of getNowDate(String format)

Description

get Now Date

License

Open Source License

Declaration

public static String getNowDate(String format) 

Method Source Code

//package com.java2s;

import java.text.*;
import java.util.Calendar;

import java.util.Locale;

public class Main {
    public static final String DEFAULT_NOW_STRING_FORMAT = "yyyyMMddHHmmssSSS";

    public static String getNowDate() {
        return getNowDate(DEFAULT_NOW_STRING_FORMAT);
    }//from w w w .  ja  v  a  2  s .  c o  m

    public static String getNowDate(String format) {

        if (format == null) {
            return null;
        }

        SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.JAPAN);

        java.util.Date date = Calendar.getInstance().getTime();

        if (date == null) {
            return null;
        }
        return sdf.format(date);
    }
}

Related

  1. getNowDate()
  2. getNowDate()
  3. getNowDate()
  4. getNowDate()
  5. getNowDate()
  6. getNowDate(String format)
  7. getNowDateShort()
  8. getNowDateStr(String formatStr)
  9. getNowDateString(String sign)