Java Time Now getCurDateTime()

Here you can find the source of getCurDateTime()

Description

get Cur Date Time

License

Apache License

Declaration

public static String getCurDateTime() 

Method Source Code

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

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

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

    public static String getCurDateTime() {
        return getCurDateTime(DEFAULTFORMAT);
    }/*from ww w.j a  v a  2 s  .  c  o m*/

    public static String getCurDateTime(String pattern) {
        return formatCalendar(Calendar.getInstance(), pattern);
    }

    public static String formatCalendar(Calendar calendar) {
        return formatCalendar(calendar, DEFAULTFORMAT);
    }

    public static String formatCalendar(Calendar calendar, String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        //sdf.setTimeZone(TimeZone.getTimeZone(timeZone));
        return sdf.format(calendar.getTime());
    }
}

Related

  1. currentTimeString()
  2. currentTimeString(String pattern)
  3. currtimeToString8()
  4. get_cur_datetime()
  5. getCurDateBefore(long time)
  6. getCurDateTIme()
  7. getCurentTimeDirsPath()
  8. getCurrDateTime()
  9. getCurrSysTime()