Java Hour Format formatFullTime(Date date)

Here you can find the source of formatFullTime(Date date)

Description

format Full Time

License

Apache License

Declaration

public static String formatFullTime(Date date) 

Method Source Code

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

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

public class Main {
    public static String formatFullTime(Date date) {
        return formatFullTime(date, TimeZone.getTimeZone("UTC"));
    }/* w ww  .j a v  a  2  s  .  com*/

    public static String formatFullTime(Date date, TimeZone timeZone) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
        if (timeZone != null) {
            format.setTimeZone(timeZone);
        }

        return format.format(date);
    }

    /**
     * Format date with UTC time zone.
     * 
     * @param date
     * @param pattern
     * @return
     */
    public static String format(Date date, String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        return sdf.format(date);
    }
}

Related

  1. formatForFileName()
  2. formatForHttpHeader(long unixTime)
  3. formatFromDate(Date date)
  4. formatFromString(String date)
  5. formatFullDate(Object date)
  6. formatHDate(java.util.Date date)
  7. formatHoraFormatadaHHMMSSStr(Date hora)
  8. formatHour(final Date date)
  9. formatHours(Locale locale, double totalhours)