UCMDB and UD Practitioners Forum (Previously CMS)
Showing results for 
Search instead for 
Do you mean 

ucmdb java api - set date property

Frequent Advisor

ucmdb java api - set date property

Hello,

 

I want to update a specific CI in ucmdb (version 8.07) using the java-api provided. Everything works except for one thing. When it comes to a date/time kind of attribute the update has no result. I tried the generic way:

newCI.setPropertyValue("host_installation_date", fileContent.get(i)[8].trim());

 

And the specific way as well (the df.parse converts the date coming from an csv file to a date of a specific format):

newCI.setDateProperty("host_installation_date", df.parse(fileContent.get(i)[8].trim()));

 

None of them worked. I tried to play around a bit with the date formats but I had no luck. Do you have any idea or hint how to set a date/time attribute using the java-api?

 

Many thanks in advance,

Barna

1 REPLY
Occasional Visitor

Re: ucmdb java api - set date property

Have you checked the API Reference of your installation. My version is 9.04, so may be it is a little bit different.

The url is:

https://server_ip:server_port/ucmdb-docs/docs/eng/doc_lib/DevRef_guide/UCMDB_JavaAPI/

or you can access the main address

https://server_ip:server_port/

and click on  "API Reference"->S

 

Click on Index and look for setDateProperty.

 

You see that the format of the Date must be a java.util.Date format, not a string format.

 

void setDateProperty(java.lang.String name,
                     java.util.Date value)

In order to verify existing CIs with date filled, you can use the method getDateProperty.

 

More generally, you can use:

setPropertyValue

void setPropertyValue(java.lang.String name,
                      java.lang.Object value)

Sets the property to the value.
The type of the property is deduced from the class of the valueparameter. The following classes are supported:

  • Boolean, Integer, Long, Float, Double and String are interpreted as their UCMDB counterparts. Using autoboxing boolean, int, long, float and doublecan also be passed.
  • byte[] is interpreted as BYTES
  • Date is interpreted as DATE
  • Iterable<String> and String[] are interpreted as STRING_LIST
  • Iterable<Integer> and int[] are interpreted as INTEGER_LIST

 

Parameters:name- name of the property value - value of the property  

 Please, let me know if you need further help.

Regards.

Francesco.

//Add this to "OnDomLoad" event