Java Time Format calFormatTime(final Calendar cal)

Here you can find the source of calFormatTime(final Calendar cal)

Description

Formats a Calendar to the application wide format for time

License

Apache License

Parameter

Parameter Description
cal the Calendar to format

Return

the formated

Declaration

public static String calFormatTime(final Calendar cal) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    public static final String TIME_FORMAT = "hh:mm a";

    /**//from w  w w  .java  2  s  . c o  m
     * Formats a {@linkplain Calendar} to the application wide format for time
     * 
     * @param cal
     *            the {@linkplain Calendar} to format
     * @return the formated {@linkplain Calendar}
     */
    public static String calFormatTime(final Calendar cal) {
        SimpleDateFormat sdf = new SimpleDateFormat(TIME_FORMAT);
        return sdf.format(cal.getTime());
    }
}

Related

  1. compareTime(String time1, String time2, String dateFormat)
  2. createTimeFormatter(String languageCode)
  3. format(long time)
  4. format(long time)