Java Time Now getNowStr()

Here you can find the source of getNowStr()

Description

get Now Str

License

Open Source License

Declaration

public static String getNowStr() 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    private static String defaultDatePattern = "yyyy-MM-dd";
    public static SimpleDateFormat dateTimeFormatter2 = new SimpleDateFormat("yyyyMMddHHmmss");

    public static String getNowStr() {
        return dateTimeFormatter2.format(new Date());
    }/* www  . ja  va2 s  .  c  o  m*/

    public static String format(Date date) {
        return format(date, getDatePattern());
    }

    public static String format(Date date, String pattern) {
        String returnValue = "";

        if (date != null) {
            SimpleDateFormat df = new SimpleDateFormat(pattern);
            returnValue = df.format(date);
        }

        return (returnValue);
    }

    public static String getDatePattern() {
        return defaultDatePattern;
    }
}

Related

  1. getNowOfDateByFormat(String format)
  2. getNowPatch()
  3. getNowSinceHour()
  4. getNowStr()
  5. getNowStr()
  6. getNowStrDateVerbose()
  7. getNowString()
  8. getNowString()
  9. getNowString(String pattern)