Java Date Now getCurrentHMS()

Here you can find the source of getCurrentHMS()

Description

get Current HMS

License

Open Source License

Declaration

public static String getCurrentHMS() 

Method Source Code

//package com.java2s;

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

public class Main {
    public static final String _DEFAULT1 = "yyyy-MM-dd HH:mm";
    public static final String _DEFAULT4 = "yyyy-MM-dd";

    public static String getCurrentHMS() {
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        Date date = new Date();
        return sdf.format(date);
    }//w w  w  .  j  a  v a2  s. c om

    public static String format(Date date) {
        return formatDate(date, _DEFAULT4);
    }

    public static String formatDate(Date date) {
        return formatDate(date, _DEFAULT1);
    }

    public static String formatDate(Date date, String style) {
        return new SimpleDateFormat(style).format(date);
    }
}

Related

  1. getCurrentDay(String pattern)
  2. getCurrentDayBegin()
  3. getCurrentDayInyyyyMMdd()
  4. getCurrentFormattedTime()
  5. getCurrentGMTTime()
  6. getCurrentISO8601Date()
  7. getCurrentJnlpTimestamp()
  8. getCurrentLastDate()
  9. getCurrentLocaleTime()