Java Date Now getCurrentDateByString(String datePattern)

Here you can find the source of getCurrentDateByString(String datePattern)

Description

get Current Date By String

License

Open Source License

Declaration

public static String getCurrentDateByString(String datePattern) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static String getCurrentDateByString(String datePattern) {

        return new SimpleDateFormat(datePattern).format(System.currentTimeMillis());
    }/*from   ww  w .  jav  a2 s. c  o  m*/

    public static String getCurrentDateByString(Date date, String datePattern) {

        return new SimpleDateFormat(datePattern).format(date);
    }

    public static long currentTimeMillis() {
        return getToday().getTime();
    }

    public static String getTime() {
        return sdfTime.format(new Date());
    }

    public static Date getToday() {
        return new Date();
    }
}

Related

  1. getCurrentDateAsNiceString()
  2. getCurrentDateAsNumericEncodedByteArray()
  3. getCurrentDateAsString()
  4. getCurrentDateAsString(DateFormat df)
  5. getCurrentDateAsString(String timestampFormat)
  6. getCurrentDateDBFormat()
  7. getCurrentDateFormat()
  8. getCurrentDateFormated()
  9. getCurrentDateInMillis()