Java Date UTC Format formatUTC(Date date, String format)

Here you can find the source of formatUTC(Date date, String format)

Description

format UTC

License

Open Source License

Declaration

public static String formatUTC(Date date, String format) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.TimeZone;

public class Main {
    public static final String FORMAT_TIME_DEFAULT = "yyyy-MM-dd hh:mm:ss z";

    public static String formatUTC(Date date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        return sdf.format(date);
    }//  w  w  w .  j  av  a2  s.  c om

    public static String formatUTC(Date date) {
        return formatUTC(date, FORMAT_TIME_DEFAULT);
    }
}

Related

  1. createUTCDateFormatter(String dateFormat)
  2. FormatAsUtc(Date date)
  3. formatAsUTC(java.util.Date date, String pattern)
  4. formatDate(Date date, String pattern, boolean toUTC)
  5. formatTimeStamp(byte[] btValue, int iOffset, int iLength, int iUtcOffset)
  6. formatUtcDateIfNotNull(final Date date)
  7. formatUtcTime(long tval)
  8. getStrTimeByUTC(long utc, String format)
  9. getUTCDateFormat()