1

my property like this:

<property name="ReadingDateTime"
     expression="//ReadingDateTime/text()"
     scope="default"
     type="STRING"
/>

Result is :1361855692325

which is in epoch format how can i convert in to noraml timezone to send db

my try is like this but its not converting it

<property name="ReadingDateTime"
     expression=" current-dateTime()-xs:dateTime('1361855692325'))"
     scope="default"
     type="STRING"
/>

any body help me pls

<property name="epoch"
     expression="get-property(SYSTEM_TIME")
     scope="default"
     type="STRING"/> 

Result:-1361855692325 its superbly giving epoch value but i want change epoch value to timestamp

Community
  • 1
  • 1
Faisal
  • 1,469
  • 2
  • 13
  • 25

1 Answers1

2

You can do this easily with the script mediator which let you use Javascript. Config looks like,

<property name="epoch" value="1361968436252"/>

<script language="js"><![CDATA[
    var t = mc.getProperty("epoch");
    var date = new Date(parseInt(t)).toString();
    mc.setProperty("newdate", date);
]]></script>

<log level="custom">
   <property name="TIMESTAMP" expression="get-property('newdate')"/>
</log>
  • thanx for u r post its helping me alot actually i am from ORACLESOA so i dont know java all the stuff.its good but when ever i am trying send this to DB using WSO2DSS it will not accept it should be like this....2012-12-18T15:26:07Z.its giving in this format: Tue Feb 26 2013 10:44:52 GMT+0530 (IST) – Faisal Feb 27 '13 at 13:26
  • Ah you want the date in ISO format. There's a Javascript function toISOString() that should return a given date in the format you want. Unfortunately it script mediator doesn't seem to like it. So you have to create the date string by hand. Like this - `var date = new Date(parseInt(t)); mc.setProperty("newdate", date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate() + 'T' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds() + 'Z');` – Chintana Wilamuna Feb 27 '13 at 15:52
  • this return every time same value when i changed t value.What is the wrong with me – Priyantha Jun 27 '17 at 12:08