Java Code Examples for javax.xml.bind.DatatypeConverter#parseDate()

The following examples show how to use javax.xml.bind.DatatypeConverter#parseDate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CloverDateConvertor.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Date parseXsdDateToDate(String value) throws DataConversionException {
    Date result = null;
    String valueType = Date.class.getName();
    
    try {
        Calendar calendar = DatatypeConverter.parseDate(value);
        result = calendar.getTime();    
    } catch(Exception e) {
        if (result != null) valueType = result.getClass().getName();
        logger.fatal("Unable to parse xsd:date to "+valueType+".",e);
        throw new DataConversionException("Unable to parse xsd:date to "+valueType+".", e);
    }
    
    return result;
}
 
Example 2
Source File: DateSchema.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
@Override
public Object convert(Object value) {
    try {
        DatatypeConverter.parseDate((String) value);
    } catch (Exception ex) {
        LOG.error(ex.getMessage(), ex);
        LOG.error("Failed to parse date", ex);
        throw new EntityValidationException(ex, "irrelevant", "doesn't matter", new ArrayList<ValidationError>());
    }
    return value;
}
 
Example 3
Source File: SAMLHelper.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
/** @deprecated */
@Deprecated
public static Calendar getNotOnOrAfterConditions(Element stsResponse) {
   return DatatypeConverter.parseDate(stsResponse.getElementsByTagNameNS("*", "Conditions").item(0).getAttributes().getNamedItem("NotOnOrAfter").getTextContent());
}
 
Example 4
Source File: SAMLHelper.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
/** @deprecated */
@Deprecated
public static Calendar getNotOnOrAfterConditions(Element stsResponse) {
   return DatatypeConverter.parseDate(stsResponse.getElementsByTagNameNS("*", "Conditions").item(0).getAttributes().getNamedItem("NotOnOrAfter").getTextContent());
}
 
Example 5
Source File: SAMLHelper.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
/** @deprecated */
@Deprecated
public static Calendar getNotOnOrAfterConditions(Element stsResponse) {
   return DatatypeConverter.parseDate(stsResponse.getElementsByTagNameNS("*", "Conditions").item(0).getAttributes().getNamedItem("NotOnOrAfter").getTextContent());
}
 
Example 6
Source File: SAMLHelper.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
/** @deprecated */
@Deprecated
public static Calendar getNotOnOrAfterConditions(Element stsResponse) {
   return DatatypeConverter.parseDate(stsResponse.getElementsByTagNameNS("*", "Conditions").item(0).getAttributes().getNamedItem("NotOnOrAfter").getTextContent());
}
 
Example 7
Source File: STSHelper.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Calendar getNotOnOrAfterConditions(Element stsResponse) {
   return DatatypeConverter.parseDate(stsResponse.getElementsByTagName("Conditions").item(0).getAttributes().getNamedItem("NotOnOrAfter").getTextContent());
}
 
Example 8
Source File: SAMLHelper.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
/** @deprecated */
@Deprecated
public static Calendar getNotOnOrAfterConditions(Element stsResponse) {
   return DatatypeConverter.parseDate(stsResponse.getElementsByTagNameNS("*", "Conditions").item(0).getAttributes().getNamedItem("NotOnOrAfter").getTextContent());
}
 
Example 9
Source File: ValueConverter.java    From java-client-api with Apache License 2.0 4 votes vote down vote up
static public Object convertToJava(String type, String value) {
  if ("xs:anySimpleType".equals(type))
    return DatatypeConverter.parseAnySimpleType(value);
  if ("xs:base64Binary".equals(type))
    return DatatypeConverter.parseBase64Binary(value);
  if ("xs:boolean".equals(type)) return StringToBoolean(value);
  if ("xs:byte".equals(type))
    return DatatypeConverter.parseByte(value);
  if ("xs:date".equals(type))
    return DatatypeConverter.parseDate(value);
  if ("xs:dateTime".equals(type))
    return DatatypeConverter.parseDateTime(value);
  if ("xs:dayTimeDuration".equals(type))
    return Utilities.getDatatypeFactory().newDurationDayTime(value);
  if ("xs:decimal".equals(type))
    return DatatypeConverter.parseDecimal(value);
  if ("xs:double".equals(type)) return StringToDouble(value);
  if ("xs:duration".equals(type))
    return Utilities.getDatatypeFactory().newDuration(value);
  if ("xs:float".equals(type)) return StringToFloat(value);
  if ("xs:int".equals(type)) return StringToInteger(value);
  if ("xs:integer".equals(type))
    return DatatypeConverter.parseInteger(value);
  if ("xs:long".equals(type)) return StringToLong(value);
  if ("xs:short".equals(type))
    return DatatypeConverter.parseShort(value);
  if ("xs:string".equals(type))
    return DatatypeConverter.parseString(value);
  if ("xs:time".equals(type))
    return DatatypeConverter.parseTime(value);
  if ("xs:unsignedInt".equals(type))
    return DatatypeConverter.parseUnsignedInt(value);
  if ("xs:unsignedLong".equals(type)) {
    BigInteger bi = DatatypeConverter.parseInteger(value);
    if (bi.compareTo(MAX_UNSIGNED_LONG) < 0) {
      return bi.longValue();
    } else {
      return bi;
    }
  } if ("xs:unsignedShort".equals(type))
    return DatatypeConverter.parseUnsignedShort(value);
  if ("xs:yearMonthDuration".equals(type))
    return Utilities.getDatatypeFactory().newDurationYearMonth(value);
  return value;
}
 
Example 10
Source File: XsValueImpl.java    From java-client-api with Apache License 2.0 4 votes vote down vote up
public DateValImpl(String value) {
    this(DatatypeConverter.parseDate(value));
}
 
Example 11
Source File: TimeChangeTest.java    From ews-java-api with MIT License 4 votes vote down vote up
private String testDate(String value) {
  Calendar cal = DatatypeConverter.parseDate(value);
  cal.setTimeZone(TimeZone.getTimeZone("UTC"));
  String XSDate = EwsUtilities.dateTimeToXSDate(cal.getTime());
  return XSDate;
}
 
Example 12
Source File: CalendarGsonConverter.java    From vraptor4 with Apache License 2.0 4 votes vote down vote up
@Override
public Calendar deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
	return DatatypeConverter.parseDate(json.getAsString());
}
 
Example 13
Source File: STSHelper.java    From freehealth-connector with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Gets the not on or after conditions.
 *
 * @param stsResponse the sts response
 * @return the not on or after conditions
 */
public static Calendar getNotOnOrAfterConditions(Element stsResponse) {
    return DatatypeConverter.parseDate(stsResponse.getElementsByTagName(SAML_CONDITIONS).item(0).getAttributes().getNamedItem(SAML_NOTONORAFTER).getTextContent());
}
 
Example 14
Source File: STSHelper.java    From freehealth-connector with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Gets the not on or after conditions.
 *
 * @param stsResponse the sts response
 * @return the not on or after conditions
 */
public static Calendar getNotOnOrAfterConditions(Element stsResponse) {
    return DatatypeConverter.parseDate(stsResponse.getElementsByTagName(SAML_CONDITIONS).item(0).getAttributes().getNamedItem(SAML_NOTONORAFTER).getTextContent());
}