Java Time Now currentTime()

Here you can find the source of currentTime()

Description

current Time

License

Open Source License

Declaration

public static String currentTime() 

Method Source Code


//package com.java2s;
import java.util.*;
import java.text.SimpleDateFormat;

public class Main {
    private static String TIME_FORMAT = "HH:mm:ss";

    public static String currentTime() {
        return formatTime(Calendar.getInstance());
    }//from  www  .  j a  v  a2  s . c  o m

    public static String formatTime(Calendar c) {
        if (c == null)
            return null;

        SimpleDateFormat df = new SimpleDateFormat(TIME_FORMAT);
        return df.format(c.getTime());
    }

    public static String formatTime(Date d) {
        if (d == null)
            return null;

        SimpleDateFormat df = new SimpleDateFormat(TIME_FORMAT);
        return df.format(d);
    }
}

Related

  1. currentTime()
  2. currentTime()
  3. currentTime()
  4. currentTime()