Java Date Now getCurrentDateString(String format)

Here you can find the source of getCurrentDateString(String format)

Description

get Current Date String

License

Open Source License

Declaration

public static String getCurrentDateString(String format) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.GregorianCalendar;

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

    public synchronized static String getCurrentDateString() {
        SimpleDateFormat format = new SimpleDateFormat(SYSTEM_DATEFORMAT_YYYY_MM_DD_HH_MM_SS);
        Date time = GregorianCalendar.getInstance().getTime();
        return format.format(time);
    }//w ww  .ja  va2 s .  c o  m

    public static String getCurrentDateString(String format) {
        Date time = GregorianCalendar.getInstance().getTime();
        return new SimpleDateFormat(format).format(time);
    }
}

Related

  1. getCurrentDateStr(String pattern)
  2. getCurrentDateString()
  3. getCurrentDateString()
  4. getCurrentDateString()
  5. getCurrentDateString(String dateFormat)
  6. getCurrentDateTime()
  7. getCurrentDateTime()
  8. getCurrentDateTime()
  9. getCurrentDateTime()