Java Time Now getNowDateTime(String strScheme)

Here you can find the source of getNowDateTime(String strScheme)

Description

get Now Date Time

License

Open Source License

Declaration

public static final String getNowDateTime(String strScheme) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static final String getNowDateTime(String strScheme) {
        String strReturn = null;//from  ww w .j a  va  2 s .c  o  m
        Date now = new Date();
        try {
            SimpleDateFormat sdf = new SimpleDateFormat(strScheme);
            strReturn = sdf.format(now);
        } catch (Exception e) {
            strReturn = "";
        }
        return strReturn;
    }

    public static final String getNowDateTime() {
        String strReturn = null;
        Date now = new Date();
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            strReturn = sdf.format(now);
        } catch (Exception e) {
            strReturn = "";
        }
        return strReturn;
    }
}

Related

  1. getNowAsString()
  2. getNowDateTime()
  3. getNowDateTime()
  4. getNowDateTime()
  5. getNowDateTime()
  6. getNowDateTimeStrConcise()
  7. getNowDayTimeLong()
  8. getNowDefault()
  9. getNowFileFormat()