Here you can find the source of getXsdDateTime(final Date d)
public static String getXsdDateTime(final Date d)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013, 2014, 2015 QPark Consulting S.a r.l. This program and the * accompanying materials are made available under the terms of the Eclipse * Public License v1.0. The Eclipse Public License is available at * http://www.eclipse.org/legal/epl-v10.html. ******************************************************************************/ import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getXsdDateTime(final Date d) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); if (d != null) { return sdf.format(d); } else {//from w ww . java 2s. c o m return sdf.format(new Date()); } } }