Here you can find the source of formatAsXsdDateTime(Date date)
Parameter | Description |
---|---|
date | the date to format. |
public static String formatAsXsdDateTime(Date date)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { private static SimpleDateFormat XSD_DATE_TIME_FORMAT = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssZ"); /**//w ww .j ava2 s .c o m * Returns a date formatted according to the xsd:dateTime data type * @param date the date to format. * @return the formatted date. */ public static String formatAsXsdDateTime(Date date) { // Set time zone on formatter XSD_DATE_TIME_FORMAT.setTimeZone(TimeZone.getDefault()); // Format the date StringBuffer buffer = new StringBuffer( XSD_DATE_TIME_FORMAT.format(date)); // Add the colon into the time offset buffer.insert(buffer.length() - 2, ':'); return buffer.toString(); } }