Java Hour Format formatShortTime()

Here you can find the source of formatShortTime()

Description

format Short Time

License

Apache License

Declaration

public static String formatShortTime() 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static final SimpleDateFormat HH_mm = new SimpleDateFormat("HH:mm");

    public static String formatShortTime() {
        return HH_mm.format(getCalendar().getTime());
    }//from www. j a  va  2  s.  c  o  m

    public static String formatShortTime(long millis) {
        return HH_mm.format(new Date(millis));
    }

    public static String formatShortTime(Calendar cal) {
        return HH_mm.format(cal.getTime());
    }

    public static String formatShortTime(Date date) {
        return HH_mm.format(date);
    }

    public static Calendar getCalendar() {
        return Calendar.getInstance();
    }

    public static Calendar getCalendar(long millis) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date(millis));
        return cal;
    }
}

Related

  1. formatRFC822(Date date, String timezone)
  2. formatRfc822Date(Date date)
  3. formatRuntime(long runtime)
  4. formatSDate(java.util.Date date)
  5. formatShortDate(java.util.Date date)
  6. formatSimpleTimeAndDateString(Date date)
  7. formatSingleFractionHours(Double updatedHours)
  8. formatSQL(Date date)
  9. formatSqlDateTime(Date value)