Here you can find the source of toXSDDateTimeString(Date d)
Parameter | Description |
---|---|
d | the date value to format |
public static String toXSDDateTimeString(Date d)
//package com.java2s; /**// ww w . j a va 2s .c om * Copyright 2005-2015 The Kuali Foundation * * Licensed under the Educational Community License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.opensource.org/licenses/ecl2.php * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { private static final String ZULU_FORMAT = "yyyy-MM-dd'T'HH:mm:ss"; private static final TimeZone ZULU_TZ = TimeZone.getTimeZone("UTC"); /** * Formats a Date into XSD dateTime format * @param d the date value to format * @return date value formatted into XSD dateTime format */ public static String toXSDDateTimeString(Date d) { return createZulu().format(d); } /** date formats are not thread safe so creating a new one each time it is needed. */ private static DateFormat createZulu() { final DateFormat df = new SimpleDateFormat(ZULU_FORMAT); df.setTimeZone(ZULU_TZ); return df; } }