Java Date Now getCurrentDateTimeStringValue()

Here you can find the source of getCurrentDateTimeStringValue()

Description

Gets current Time in xsd:dateTime format.

License

Open Source License

Return

the current date time string value

Declaration

public static String getCurrentDateTimeStringValue() 

Method Source Code

//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;
    }
}

Related

  1. getCurrentDateTimeForShow()
  2. getCurrentDateTimeISO8601()
  3. getCurrentDateTimeObj(String dateTime, String format)
  4. getCurrentDateTimeString()
  5. getCurrentDateTimeString(String returnFormat)
  6. getCurrentDateToString(String pattern)
  7. getCurrentDateWithDot()
  8. getCurrentDay()
  9. getCurrentDay()