Here you can find the source of getCurrentDateTimeStringValue()
public static String getCurrentDateTimeStringValue()
//package com.java2s; /*/*from w w w. j a v a 2 s . c o m*/ * Copyright (c) 2009-2011 Gemeente Rotterdam * * This program is free software: you can redistribute it and/or modify * it under the terms of the European Union Public Licence (EUPL), * version 1.1 (or 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 * European Union Public Licence for more details. * * You should have received a copy of the European Union Public Licence * along with this program. If not, see * http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1 */ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { /** * Gets current Time in xsd:dateTime format. * * @return the current date time string value */ public static String getCurrentDateTimeStringValue() { Calendar cal = Calendar.getInstance(); Date thisDate = cal.getTime(); SimpleDateFormat formatterDate = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formatterTime = new SimpleDateFormat("HH:mm:ss"); String currDate = formatterDate.format(thisDate) + "T" + formatterTime.format(thisDate); return currDate; } }