Java Now now(String dateFormat)

Here you can find the source of now(String dateFormat)

Description

Trasnforms String -->

License

Apache License

Parameter

Parameter Description
dateFormat a parameter

Declaration

public static String now(String dateFormat) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Calendar;

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

    /**/*from ww  w . j  av  a 2  s  .  c om*/
     * Trasnforms String -->
     * @param dateFormat
     * @return
     */
    public static String now(String dateFormat) {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        return sdf.format(cal.getTime());
    }

    public static String now() {
        return now(DATE_FORMAT_NOW);
    }
}

Related

  1. now()
  2. now()
  3. now()
  4. now(String dateFormat)
  5. now(String dateFormat)
  6. now(String dateFormat)
  7. now(String formatStr)
  8. now(String pattern)
  9. now(String s, Date date)