Java Date Now getCurrentDateAsString()

Here you can find the source of getCurrentDateAsString()

Description

get Current Date As String

License

Open Source License

Declaration

public synchronized static String getCurrentDateAsString() 

Method Source Code

//package com.java2s;

import java.text.DateFormat;

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

public class Main {
    public static final DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

    public synchronized static String getCurrentDateAsString() {
        return DEFAULT_DATE_FORMAT.format(Calendar.getInstance().getTime());
    }//from ww w  .  j  a v  a  2s. c om

    public static String getCurrentDateAsString(String dateFormat) {
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        return sdf.format(Calendar.getInstance().getTime());
    }
}

Related

  1. getCurrentDateAllformated()
  2. getCurrentDateAndTime()
  3. getCurrentDateAndTimeFormat()
  4. getCurrentDateAsNiceString()
  5. getCurrentDateAsNumericEncodedByteArray()
  6. getCurrentDateAsString(DateFormat df)
  7. getCurrentDateAsString(String timestampFormat)
  8. getCurrentDateByString(String datePattern)
  9. getCurrentDateDBFormat()