cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
782
Views
0
Helpful
0
Comments
cdnadmin
Level 11
Level 11
This document was generated from CDN thread

Created by: Ivan Fernandez on 07-03-2013 05:03:33 AM
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...

Subject: RE: New Message from Ivan Fernandez in Customer Voice Portal (CVP) - Genera
Replied by: Hemal Mehta on 07-03-2013 07:22:58 AM
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.

Subject: Re: New Message from Ivan Fernandez in Customer Voice Portal (CVP) - Genera
Replied by: Janine Graves on 07-03-2013 09:08:58 AM
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

Subject: RE: Get hours minutes and seconds
Replied by: Zelino Rocha on 08-04-2013 08:07:22 AM
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

Subject: Re: New Message from Zelino Rocha in Customer Voice Portal (CVP) - General
Replied by: Janine Graves on 08-04-2013 10:33:13 AM
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?

Subject: Re: New Message from Zelino Rocha in Customer Voice Portal (CVP) - General
Replied by: Janine Graves on 08-04-2013 10:47:13 AM
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());
}

Subject: RE: Get hours minutes and seconds
Replied by: Jameson Gagnepain on 08-04-2013 11:28:02 AM
Zelino,
If the milliseconds value is the same, perhaps you didn't actually create a new Date()? Dates are static once created.

Subject: Re: New Message from Zelino Rocha in Customer Voice Portal (CVP) - General
Replied by: Janine Graves on 08-04-2013 11:36:13 AM
Try the java code that I posted. It worked for me and gave me a
different millisecond value.

Subject: RE: Re: New Message from Zelino Rocha in Customer Voice Portal (CVP) - Gene
Replied by: Zelino Rocha on 08-04-2013 11:12:53 AM
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.
 

Subject: RE: Get hours minutes and seconds
Replied by: Zelino Rocha on 12-04-2013 07:25:01 AM
Hi,
Thank you very much for your help Janine. It's working now.
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links