Here you can find the source of dateToXsdDateTime(Date date)
Parameter | Description |
---|---|
date | the date to parse |
public static String dateToXsdDateTime(Date date)
//package com.java2s; /*// w w w.j a v a 2 s . co m * $Id: DateUtils.java 327 2014-01-27 13:07:13Z blaser $ * * Copyright (C) 2006-2012 by Bundesamt f?r Justiz, Fachstelle f?r Rechtsinformatik * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import javax.xml.bind.DatatypeConverter; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /** * Converts a Date object to the corresponding XSD DateTime String. * * @param date the date to parse * @return corresponding XSD DateTime */ public static String dateToXsdDateTime(Date date) { Calendar calendar = GregorianCalendar.getInstance(); calendar.setTime(date); return DatatypeConverter.printDateTime(calendar); } }