Here you can find the source of dateToW3CDTF(Date date)
Parameter | Description |
---|---|
date | Date to convert to W3C Date and Time Format |
public static String dateToW3CDTF(Date date)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final ThreadLocal<SimpleDateFormat> w3cdtf = new ThreadLocal<SimpleDateFormat>() { protected SimpleDateFormat initialValue() { try { return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); } catch (Exception e) { throw new Error("Exception in static initializer: " + e.toString()); }/*w w w.j av a 2 s . c o m*/ } }; /** * Creates a String that represents the Date passed to it in W3C Date and * Time Format. * * @param date * Date to convert to W3C Date and Time Format * @return String that represents the Date passed to it in W3C Date and Time * Format */ public static String dateToW3CDTF(Date date) { String s = w3cdtf.get().format(date); int index = s.length() - 2; return s.substring(0, index) + ":" + s.substring(index); } }