Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Time.valueOf(String) Convert String into Time

I am trying to use expression editor to change string in time format(10:10:00) to the actual time format (T[10:10:00]). The syntax is Time.valueOf(string)but I keep getting errors.

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: Time.valueOf(String) Convert String into Time

I was able to get this to work in the script editor as follows:

Create one String Variable called StringTime & make the default value "10:10:00 AM". Next

create one Time Variable called RealTime

Using the "Set" Step click on "properties". In the first drop down box select the variable RealTime. In the second drop down box click on ... to launch the Expressions Editor.

When the Expressions Editor launches, type the following:

RealTime.valueOf(StringTime)

Click OK. Then OK again.

The Set step should look like:

RealTime = RealTime.valueOf(StringTime)

Also make sure your string value designates either AM or PM such as "10:10:00 AM"

Hope this helps. Please rate all posts!!

3 REPLIES
Cisco Employee

Re: Time.valueOf(String) Convert String into Time

I was able to get this to work in the script editor as follows:

Create one String Variable called StringTime & make the default value "10:10:00 AM". Next

create one Time Variable called RealTime

Using the "Set" Step click on "properties". In the first drop down box select the variable RealTime. In the second drop down box click on ... to launch the Expressions Editor.

When the Expressions Editor launches, type the following:

RealTime.valueOf(StringTime)

Click OK. Then OK again.

The Set step should look like:

RealTime = RealTime.valueOf(StringTime)

Also make sure your string value designates either AM or PM such as "10:10:00 AM"

Hope this helps. Please rate all posts!!

New Member

Re: Time.valueOf(String) Convert String into Time

hi

When I try this I get the following error

"For input String ; 0 AM nested exception is

Java.langNumber Format exception

My String value is 14:00:15 AM

Re: Time.valueOf(String) Convert String into Time

Wow, this thread is 3 years old....nice find.

Were you not satisfied with the people helping you in your original thread?

https://supportforums.cisco.com/message/3030538

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
352
Views
0
Helpful
3
Replies
CreatePlease to create content