Java XML Date dateToDouble(Object value)

Here you can find the source of dateToDouble(Object value)

Description

date To Double

License

Apache License

Declaration

public static Double dateToDouble(Object value) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;

import java.util.TimeZone;

import javax.xml.bind.DatatypeConverter;

public class Main {
    public static Double dateToDouble(Object value) {
        Double ret = new Double(0.);
        if (value != null && value instanceof String) {
            TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
            try {
                Calendar cal = DatatypeConverter.parseDateTime((String) value);
                long diff = cal.getTimeInMillis() + 2209161600000l; //30.12.1899
                ret = diff / 86400000.;//from w w  w.j  a  v  a  2  s  .  co  m
            } catch (IllegalArgumentException e) {
            }
            TimeZone.setDefault(null);
        }
        return ret;
    }
}

Related

  1. convertDate(String date)
  2. dateToString(Date date)
  3. dateToString(Date date)
  4. dateToXsdDateTime(Date date)
  5. extractXsdDatetime(String string)