Java Date Now getCurrentTimeString(String pattern)

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

Description

get Current Time String

License

Apache License

Declaration

public static String getCurrentTimeString(String pattern) 

Method Source Code

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

import java.text.Format;

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static String getCurrentTimeString() {
        Date now = Calendar.getInstance().getTime();
        Format formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(now);
    }// ww w.j  av  a2 s.  com

    public static String getCurrentTimeString(String pattern) {
        Date now = Calendar.getInstance().getTime();
        Format formatter = new SimpleDateFormat(pattern);
        return formatter.format(now);
    }
}

Related

  1. getCurrentTimestampAsISOString()
  2. getCurrentTimestampString()
  3. getCurrentTimeStr()
  4. getCurrentTimeStr()
  5. getCurrentTimeString(String format)
  6. getCurrentToNextDaySecond()
  7. getCurrentUnixTime()
  8. getCurrentUTCDate()
  9. getCurrentUtcDate()