cancel
Showing results for 
Search instead for 
Did you mean: 

Unix timestamp conversion to human readable representation ...

Former Member
0 Kudos

Hi,

I map unix timestamps from MaxDB to the controller context of Web Dynpro and display the results in a table. Is there a smart way to convert the timestamps to human readable date and time? Maybe some way to manipulate the table values with a function before they are written ..?

For now, I create a new node in the context and manually set each value with the according date/time representation ... but thats pretty cumbersome.

Thank you very much for your help!

Cheers,

boris

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Boris,

Check http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html


Date currentTime_1 = new Date(longUnixTimestamp);
String dateString = formatter.format(currentTime_1);

I would suggest you to create a calculated attribute under the same node as initial timestamp value and return a result of SimpleDateFormat.format().

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim,

thanks for your answer. My problem is not so much the conversion but the way I handle the data in the context: Do I have to convert and set context attributes manually, or is there a way to map the unixtimestamps to a table but convert them before with some onDisplay-function ...?

Cheers,

boris

former_member182372
Active Contributor
0 Kudos

Hi Boris,

Use type long as primary data storage. Create calculated attribute with type Date on the same level as primary long attribyte and in getter put something like:

return new Date(valueFromUnixTimeStamp);

. WD runtime will take care abput formating (using user locale).

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Thanks Maksim, the keyword was "calculated attribute"!

boris

Answers (0)