« Back to General Discussion - All Versions

RE: New Message from Ivan Fernandez in Customer Voice Portal (CVP) - Genera

Combination View Flat View Tree View
Threads [ Previous | Next ]
Hi
I can get the date of the month, the month and the year and  minutes? using the substituon element and selecting date current but i ant get the time e.g 10:43:12 .
I can use java as a workaround but was wondering if it can be done using one of the call studio elements or if i am missing something...

Do you want to get the current date and time and use it in the flow ? You can use java or just build a custom element which will do that.
Hemal

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Thursday, March 07, 2013 5:04 AM
To: cdicuser@developer.cisco.com
Subject: New Message from Ivan Fernandez in Customer Voice Portal (CVP) - General Discussion - All Versions: Get hours minutes and seconds

Ivan Fernandez has created a new message in the forum "General Discussion - All Versions": -------------------------------------------------------------- Hi
I can get the date of the month, the month and the year and minutes? using the substituon element and selecting date current but i ant get the time e.g 10:43:12 .
I can use java as a workaround but was wondering if it can be done using one of the call studio elements or if i am missing something...
--
To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/community/-/message_boards/view_message/12742078 or simply reply to this email.

You can get the hour and minutes and concatenate them in the Data tab as you assign it into a Session variable named Time. But you can't get seconds. And the dates/times aren't padded with "0" Something like: Session Data Name: Time Value: {Current.HOUR}:{Current:MINUTE} Janine Graves TrainingTheExperts.com

Hi,

Could you get this working? I have a related problem:
 
I'm trying to get the time difference (in minutes and seconds) between  two distinct moments in my call flow.
I have one Java class in the beggining of the flow, which stores the current time in session data, after that, the app plays on hold music. At any time the user can press one key, captured by a hotlink which points to another Java class, where I get the the current time again, and calculate the time difference between now, and the initial time (stored previously in data session). The problem is: when I try to get the current time after play on hold music, it gives me the same time as the initial.

I tried with

java.sql.Time time = new Time(System.currentTimeMillis());

time.getTime();

Date  date = new Date();

date.getTime();

When I run this code localy, I get the time difference, which made me think it might be some CVP issue:

Date  date1 = new Date();
System.out.println(date1); Mon Apr 08 12:53:33 BST 2013
System.out.println(date1.getTime()); 1365422013766
 
Thread.sleep(3000);
 
Date date2 = new Date();
System.out.println(date2); Mon Apr 08 12:53:36 BST 2013
System.out.println(date2.getTime()); 1365422016786

I'd be grateful with any help on this.

Thanks

Zelino,

I assume you didn't show the entire java code you're executing - because
I don't see that you are creating session data.
In the java class when you create the session data:
actionData.setSessionData("date1",date1);

And in the java class when you want to retrieve the date1 from session
data, you'll need
Date date1 = (Date) actionData.getSessionData("date1");


Did you do the above?

This works:

//if date1 doesn't exist, it's the first time in, so create it
//if date1 exists, then this is the 2nd time in - get the difference

Date date1=(Date) actionData.getSessionData("date1");
if(date1==null){
date1 = new Date();
data.setSessionData("date1",date1);
} else {
Date date2== new Date();
System.out.println("duration="+(date2.getTime()-date1.getTime()));
data.setSessionData("duration", date2.getTime()-date1.getTime());
}

Hi Janine, I will put all the relevant code here:
 
In the beggining of the flow, I execute this code
 
Class1
 
Date  date = new Date();
 
actionAPI.setSessionData("begginingOfCall", date.getTime()+"");
 
 
Then I play music on old for a few minutes, and after that, I run a second Java class:
 
 
Class2
 
String aux = ""+actionAPI.getSessionData("begginingOfCall");
 
long beggining= Long.parseLong(aux);
 
 
Date date = new Date();
 
long wainting_time = date.getTime()-beggining;
 
 
The problem is, when I run this code
 
actionAPI.addToLog("CurrentTime:", ""+date.getTime());
actionAPI.addToLog("Beggining of call:", ""+beggining);
 
I note that the value in miliseconds is the same, for date.getTime(), and the variable beggining, like if the time hasn't passed while the music was playing.
 

Zelino,
If the milliseconds value is the same, perhaps you didn't actually create a new Date()? Dates are static once created.

Try the java code that I posted. It worked for me and gave me a
different millisecond value.

Hi,
Thank you very much for your help Janine. It's working now.