private XMLGregorianCalendar populateDate(OpaAttribute input) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date date = null; XMLGregorianCalendar xmlDate = null; try { date = df.parse(input.getValue()); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date); xmlDate = DatatypeFactory.newInstance() .newXMLGregorianCalendarDate( cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), cal.getTimeZone().LONG); } catch (ParseException e) { throw new RuntimeException("Cannot convert inputValue to Date : " + input.getValue()); } catch (DatatypeConfigurationException e) { throw new RuntimeException("Cannot convert inputValue to Date : " + input.getValue()); } return xmlDate; }
private void populateAttributeTypeValue(AttributeType attributeType, OpaAttribute input) { switch (input.getValueType()) { case _NUMBER: case _CURRENCY: attributeType.setNumberVal(new BigDecimal(input.getValue())); break; case _BOOLEAN: attributeType.setBooleanVal(new Boolean(input.getValue())); break; case _DATE: attributeType.setDateVal(populateDate(input)); break; case _TEXT: break; default: throw new RuntimeException("Unsupported AttributeType :" + input.getValueType()); } }