Java Hour Format formatXsdDateTime(Date d)

Here you can find the source of formatXsdDateTime(Date d)

Description

format Xsd Date Time

License

Open Source License

Declaration

public static String formatXsdDateTime(Date d) 

Method Source Code

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

import java.text.DateFormat;

import java.text.SimpleDateFormat;

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

public class Main {
    public static final String XSD_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";

    public static String formatXsdDateTime(Date d) {
        return formatDate(d, XSD_DATETIME_FORMAT);
    }/*from www  .j  a v a 2  s .  c  o m*/

    public static String formatXsdDateTime(Date d, TimeZone tz) {
        return getDateFormat(XSD_DATETIME_FORMAT, tz).format(d);
    }

    public static String formatDate(Date date, String pattern) {
        if (date == null) {
            return null;
        }
        return getDateFormat(pattern).format(date);
    }

    public static DateFormat getDateFormat(String pattern) {
        return getDateFormat(pattern, TimeZone.getDefault());
    }

    public static DateFormat getDateFormat(String pattern, TimeZone tz) {
        DateFormat result = new SimpleDateFormat(pattern);
        result.setTimeZone(tz);
        return result;
    }
}

Related

  1. formatWCPDate(String date, String sFormat)
  2. formatWithAge(Date date, String dateFormat, String suffix)
  3. formatWithSql92Date(Date date)
  4. formatXEP0082Date(Date date)
  5. formatXsdDate (final Date date)
  6. getFormattedHoursByMinutes(int minutes)
  7. getHHmm()
  8. getHHMM(Date date)
  9. getHHMMSS()