Java XML Date string2millis(String lexicalXSDDateTime)

Here you can find the source of string2millis(String lexicalXSDDateTime)

Description

Converts given string to milliseconds from Unix Epoch

License

Mozilla Public License

Parameter

Parameter Description
lexicalXSDDateTime - A string containing lexical representation of xsd:datetime

Return

Milliseconds since 1970-01-01

Declaration

public static long string2millis(String lexicalXSDDateTime) 

Method Source Code

//package com.java2s;
/* //from  w w w. ja v  a  2s .  c  o m
 * SMART FP7 - Search engine for MultimediA enviRonment generated contenT
 * Webpage: http://smartfp7.eu
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * The Original Code is Copyright (c) 2012-2013 Athens Information Technology
 * All Rights Reserved
 *
 * Contributor:
 *  Nikolaos Katsarakis nkat@ait.edu.gr
 */

public class Main {
    /**
     * Converts given string to milliseconds from Unix Epoch
     * 
     * @param lexicalXSDDateTime
     *            - A string containing lexical representation of xsd:datetime
     * @return Milliseconds since 1970-01-01
     */
    public static long string2millis(String lexicalXSDDateTime) {
        long res;
        try {
            res = javax.xml.bind.DatatypeConverter.parseDateTime(lexicalXSDDateTime).getTimeInMillis();
        } catch (IllegalArgumentException e) {
            return -1;
        }
        return res;
    }
}

Related

  1. isValidDateUpdatedType(Calendar value)
  2. printDate(final Calendar date)
  3. printDate(java.util.Date dt)
  4. printDateTime(final Date date)
  5. printDateUpdatedType(Calendar value)
  6. toDate(String date)
  7. toJavaDate(String dateStr)
  8. toTimeZone(String date, String toTimeZone)