Java Now getStringNowTime()

Here you can find the source of getStringNowTime()

Description

get String Now Time

License

Open Source License

Declaration

public static String getStringNowTime() 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String getStringNowTime() {
        Date date = new Date();
        String dateStr = dateFormat(date);

        return dateStr;
    }//from w  w w  . java  2s. c  o  m

    public static Date dateFormat(String date, String dateFormat) {
        if (date == null)
            return null;
        SimpleDateFormat format = new SimpleDateFormat(dateFormat);
        if (date != null)
            try {
                return format.parse(date);
            } catch (Exception ex) {
            }
        return null;
    }

    public static Date dateFormat(String date) {
        return dateFormat(date, "yyyy-MM-dd HH:mm:ss");
    }

    public static String dateFormat(Date date, String dateFormat) {
        if (date == null)
            return "";
        SimpleDateFormat format = new SimpleDateFormat(dateFormat);
        if (date != null)
            return format.format(date);

        return "";
    }

    public static String dateFormat(Date date) {
        return dateFormat(date, "yyyy-MM-dd HH:mm:ss");
    }
}

Related

  1. getDisplayDateNow()
  2. getFormatNowDateTime(String formatStr)
  3. getFormattedDateNow(@Nonnull final String sFormat)
  4. getInviteCodeByNowDate()
  5. getShortNowTime()
  6. getStringOfNowDate(String fFormatStr)
  7. getTimeNow()
  8. getTimeNow(Date theTime)
  9. getTimeNowAsString(String pattern)