Time.valueOf(String) Convert String into Time

Answered Question
Oct 12th, 2007
User Badges:

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,

Correct Answer by Dennis Fogler about 9 years 8 months ago

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!!

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
Correct Answer
Dennis Fogler Mon, 10/15/2007 - 06:35
User Badges:
  • Cisco Employee,

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!!

mymite060708 Fri, 03/05/2010 - 12:05
User Badges:

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

Actions

This Discussion