VMware {code} Community
matrix123321
Contributor
Contributor

How to use "UpdateDateTimeConfig"..

Hi everyone,

can u tell me how to use "UpdateDateTimeConfig()" function in VI SDK 2.5

0 Kudos
4 Replies
admin
Immortal
Immortal

You call "updateDateTime()" method using HostDateTimeSystem managed object. This object has recently been added into VI SDK 2.5. You can get the reference of "HostDateTimeSystem", from "configManager"data object of "HostSystem" managed object.

Sample code snippet is as follows:

HostConfigManager hostconfig

= (HostConfigManager)ecb.getServiceUtil3().getDynamicProperty(hmor,"configManager");

ManagedObjectReference datatimesystem = hostconfig.getDateTimeSystem();

Calendar cal = Calendar.getInstance();

System.out.println("Time " + cal.getTime());

ecb.getServiceConnection3().getService().updateDateTime(datatimesystem,cal);

Here hmof is the Managed Object reference of the HostSystem. From hmor we fected the HostConfigManager data object. And then called the updateDateTime(). We are setting the Date time of the server according to the calender date-time of the client machine.

matrix123321
Contributor
Contributor

hey thanks for the help..but say i want to set the time to 13:00..how to do that..?also how to set the time zone say i want to set it to +5:30 GMT

0 Kudos
admin
Immortal
Immortal

The desired time-zone can be set using "TimeZone" property of Calender object and then passing this Calender object to updateDateTime function, code-sample illustrating the usage is as follows:

hostConfigManager hostconfig

= (HostConfigManager)ecb.getServiceUtil3().getDynamicProperty(hmor1,"configManager");

ManagedObjectReference datatimesystem = hostconfig.getDateTimeSystem();

Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Asia/Calcutta"));

Date dt = new Date(82,8,13,10,5);

cal.setTime(dt);

System.out.println("Time " + cal.getTime());

ecb.getServiceConnection3().getService().updateDateTime(datatimesystem,cal);

0 Kudos
matrix123321
Contributor
Contributor

thanks again seemankij

0 Kudos