Java Date Now getCurrentTimeString(String format)

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

Description

get Current Time String

License

Open Source License

Declaration

public static String getCurrentTimeString(String format) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String getCurrentTimeString() {
        Date cal = new Date();

        SimpleDateFormat newSDF = new SimpleDateFormat("HH:mm:ss");
        String timeStr = newSDF.format(cal);

        return timeStr;
    }/*  www .j a  va2 s .co m*/

    public static String getCurrentTimeString(String format) {
        Date cal = new Date();

        SimpleDateFormat newSDF = new SimpleDateFormat(format);
        String timeStr = newSDF.format(cal);

        return timeStr;
    }
}

Related

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