Java Date Now getCurrentString(String pattern)

Here you can find the source of getCurrentString(String pattern)

Description

get Current String

License

Open Source License

Declaration

public static String getCurrentString(String pattern) 

Method Source Code

//package com.java2s;

import java.text.*;
import java.util.Calendar;

import java.util.TimeZone;

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

    public static String getCurrentString() {
        return getCurrentString(DEFAULT_SIMPLEDATE_FORMAT);
    }/*w  ww .  j ava2 s.  c o  m*/

    public static String getCurrentString(String pattern) {
        SimpleDateFormat f = new SimpleDateFormat(pattern);
        return f.format(Calendar.getInstance(TimeZone.getDefault()).getTime());
    }
}

Related

  1. getCurrentMonthString(Calendar calendar)
  2. getCurrentODSDate()
  3. getCurrentPlainDate()
  4. getCurrentQuarter()
  5. getCurrentSecond()
  6. getCurrentStringDate()
  7. getCurrentStringDate(String pattern)
  8. getCurrentStringDateYMD()
  9. getCurrentStrTimeMills()