cancel
Showing results for 
Search instead for 
Did you mean: 

Converting a Java style date into useful format

Former Member
0 Kudos

If I am calling a web service that returns a Java style date as a numeric value, such as 1177651563767 (milliseconds since 1 Jan 1970), how can I display this as a human readable date (hh:mm:ss dd-mm-yyyy? I have looked at the <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/40/a228173435437394f54c56de571ca4/frameset.htm">SAP help pages on date functions</a> and the

<a href="https://wiki.sdn.sap.com/wiki/display/VC/DateandTime+Formats">wiki page on date and time formats</a>, but neither seems to help.

My Java date is a numeric.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Michael,

I think a simple solution is not available and all the functions about time, date or other country specific units make problems.

I think you can try to use a complex VC formula which compute years, days, hours, minutes, seconds and so on then compute your date.

Another option I see is that you can write an ABAP RFC for converting the date.

Another question back to you, isn't it possible that your webserivce returns you a date readable for humans?

Best Regards,

Marcel

Former Member
0 Kudos

Hi Marcel

Thanks for the reply. It's not what I wanted to see, but at least I know there's nothing built in!

The webservice is a standard SAP one and only returns long dates

Cheers

Former Member
0 Kudos

Hi Michael,

you can call the webservice with another webservice or an RFC and then use Java or ABAP to convert the value into the right format. My opinion is as you mentioned that there is no way with VC. Maybe you can use a time function (DADD as it is described <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/40/a228173435437394f54c56de571ca4/frameset.htm">here</a> and sum up to 01/01/1970 your [value in seconds]/60 this should work, but I never tested it.

Maybe this works, but this isn't a good solution anyway.

Best Regards,

Marcel

Former Member
0 Kudos

Thanks Marcel. I thought I would start trying to calculate some dates, but when I make a virtual field in my output table with type numeric and a default value of @TimeStamp / (3600 * 24 * 10000), I get a blank result. In fact, I get a blank result for any virtual fields! Even a simple string with a default value of "ABC" displays as spaces.

Any ideas?

Former Member
0 Kudos

Please ignore my last rambling! I was using the wrong type of field in my table - I should have been using Expression Box. I have just about maanged to get my model working - I'll post details later.

Cheers

Former Member
0 Kudos

Hi Michael,

I'm curiouse about your solution. Maybe this would be a good one for our wiki.

Best Regards,

Marcel

Former Member
0 Kudos

Hi Marcel

I've described the model <a href="https://wiki.sdn.sap.com/wiki/display/VC/AportalactivityreportusingVisualComposer">here</a>, but basically I took the long date, worked out the number of days by dividing by 24 3600 1000 and added that to 01-01-1970 with DADD.

The hours are the remainder after taking away the days * 2436001000 and then divided by 3600*1000.

My wiki page is a bit more complicated as I wanted to allow for a timzone offset. I couldn't get this from the user info, but I do display the user's timezone name as a hint.

Cheers

Former Member
0 Kudos

Hi Michael,

you have done a great job! Very helpful Wiki entry!

Best Regards,

Marcel

Former Member
0 Kudos

Thanks! I have a little problem - I can't get a default value appearing in my input fields in the seelction screen. I set a default value, but it appears blank. The same with my radio button group - I want to set a default, such as "Day", but it doesn't appear. When I generate Webdynpro it seems to work, but not Flash.

Any ideas?

Cheers

Former Member
0 Kudos

It seems to be a flash problem. Do you have startpoint to every form so that the form will be initialized during runtime?

Best Regards,

Marcel

Former Member
0 Kudos

I'll have to look at that. I have one form that is my starting form that then sends its data to another form. It is this second form that is missing the default values. My main form is only there so I can call my first web service. Is there someway to get this executed without the need for a Submit button?

Cheers

Answers (0)