Java Date Format As formatDateUsingW3C(Date date)

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

Description

Use to produce date Strings in the W3C date format

License

Apache License

Parameter

Parameter Description
date a parameter

Exception

Parameter Description
DatatypeConfigurationException an exception

Declaration

public static String formatDateUsingW3C(Date date) 

Method Source Code


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

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

public class Main {
    /**//from ww  w.  j ava  2s  .c  o  m
     * Use to produce date Strings in the W3C date format
     * 
     * @param date
     * @return
     * @throws DatatypeConfigurationException 
     */
    public static String formatDateUsingW3C(Date date) {
        String w3cDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(date);
        return w3cDate = w3cDate.substring(0, 22) + ":" + w3cDate.substring(22, 24);
    }
}

Related

  1. formatDateToDefault(Date date)
  2. formatDateToMD(Date date)
  3. formatDateToMinutes(Date date)
  4. formatDateToUTC(Date date)
  5. formatDateToUTC(final Date date)
  6. formatDateUTC(Date d)
  7. formatDateUTC(Date date)
  8. formatDateW3C(Date date)
  9. formatDateWithMilliseconds(DateFormat aFormat, Date aDate)