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. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

Unparseable Date

                   Greetings all,  I have a situation where I am pulling information from a database, one piece of which is a date.  The endgame here is to have the date read to the caller.  In this case the database holds only the month and date so when I create my set command to put the string into a date ...

set transactionDate (a date variable) = dateOfTransaction.substring(0,2) + "/" + dateOfTransaction.substring(2)

The script blows up with the unparseable date "10/14".  I assume it needs mmddyyyy instead of mmdd.  Later on I use the create generated prompt step with the date constructor to read the date back to the caller.  If I make transactionDate a string variable rather than a date variable, will the generated date prompt read 10/14 as a October 14th?

it will only take a minute to try it but if anyone out there has any idea, please let me know.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Unparseable Date

Correct, it's not valid to format a date like that.  To keep going in the same direction, just append the current year.

Set transactionDate = new Date(dateOfTransaction.substring(0, 2) + "/" + dateOfTransaction.substring(2) + "/" + D[now].year)

There's probably very few times when this would be incorrect.  I.e., The date is Feb 29, and you append 2014 to it, when in reality it was meant to be 2012.

Now, in your Create Generated Prompt step, use Generator Type of Date, Constructor Type of (date, skip.current.year) and then set the two arguments to:

date: transactionDate

skip.current.year: true

That should do it.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
4 REPLIES
New Member

Unparseable Date

Well, that didn't work, I cannot set a generated date prompt from a string variable. I guess my question now is what do I have to do to have the date variable to not expect mmddyyyy?

Re: Unparseable Date

Correct, it's not valid to format a date like that.  To keep going in the same direction, just append the current year.

Set transactionDate = new Date(dateOfTransaction.substring(0, 2) + "/" + dateOfTransaction.substring(2) + "/" + D[now].year)

There's probably very few times when this would be incorrect.  I.e., The date is Feb 29, and you append 2014 to it, when in reality it was meant to be 2012.

Now, in your Create Generated Prompt step, use Generator Type of Date, Constructor Type of (date, skip.current.year) and then set the two arguments to:

date: transactionDate

skip.current.year: true

That should do it.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Re: Unparseable Date

Thank you Anthony.  Looking at the answer I am a bit embarassed that I didn't find this one myself.

Re: Unparseable Date

No worries.  For what its worth, the UCCX editor puts in front of you deprecated object and methods, and doesn't realy encourage you to do things in new ways.

If you look at the Java documentation for java.util.Date, you will see that creating a new Date in this fashion has been superceded by java.text.DateFormat.parse("October 14, 2013").

As of JDK 1.1, the Calendar class should be used to convert between dates and time fields and the DateFormat class should be used to format and parse date strings. The corresponding methods in Date are deprecated. 
Date(String s) Deprecated. As of JDK version 1.1, replaced by DateFormat.parse(String s).

Source: http://docs.oracle.com/javase/6/docs/api/java/util/Date.html

The drawback to moving to something new, and aware from the standard practices of UCCX is that other telecom administrators will be less familiar with these new ways, and administration/troubleshooting will be more complex.

The benfits are numerous, to include compliance, as well as better features and more suscinct code.  Think of the poor little old Java Memory Heap at 256MB*.

*UCCX 8.5(1)SU4 ES02_15 doubles JVM Heap to 512MB

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
326
Views
0
Helpful
4
Replies