How to calculate hours between two dateTime node in BPEL.

In my BPEL there's a requirement need calculate hours between two dateTime type..
I tried 2 solutions, both of them failed:
1. use xslt calculate duration(xml type, like PT12H) between two dateTime, and then use embedded java code to get the hours.. The problem is : I need to parse the xml duration format...(like this real one: -P80DT17H47M36S....), and to parse it in java , maybe have the same problem with solution 2..
* [Subtracting 2 dateTime values into a duration using XPath 2.0|http://blogs.oracle.com/rammenon/2007/07/subtracting_2_datetime_values.html]
2. use embed java code, but it seems we can't use some class in embedded java code:
my code(input begin, end both dateTime in xml. output: diff, int in xml):
1 System.out.println("\n\nTimeTestBegin");
2 String begin=getVariableData("begin").toString();
3 String end=getVariableData("end").toString();
4 System.out.println(begin+"-----"+end);
5 //Class c1=Class.forName("javax.xml.datatype.XMLGregorianCalendar");
6 //Class c2=Class.forName("javax.xml.datatype.DatatypeFactory");
7 //System.out.println(c1.getName());
8 //System.out.println(c2.getName());
9 javax.xml.datatype.XMLGregorianCalendar beginTime = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(begin);
10 javax.xml.datatype.XMLGregorianCalendar endTime = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(end);
11 long diff=beginTime.toGregorianCalendar().getTimeInMillis()-endTime.toGregorianCalendar().getTimeInMillis();
12 setVariableData("diff",String.valueOf(diff/1000/3600));
13 System.out.println("DIFF======"+diff/1000/3600);
14 System.out.println("TimeTestEnd");
it's said can't compile java class, but can't find the detail error, I think the problem is how to import java class to embedded java code activity(use full package name like above code don't work), when I remove line 9-13, no compile error..
BTY: Jdeveloper is a IDE support java, but why the embedded java activity's edit window only have a simple "java code" editor, too simple that it can only edit you code snippet...
3.There's another sulotion: extend BPEL xpath functions(add a new function), but in my project, modify BPEL server(soa server)'s config file is not allowed..
Anyone know easy solution to my problem?
Thanks.

Hi, All,
I found the cause. Sorry, it's my mistake..
below line have a DatatypeConfigurationException:
javax.xml.datatype.DatatypeFactory.newInstance()
When I test my java code snippet, I coped the code snippet to one of my java class in eclipse, and put it in a method to check if there's compile error, but I didn't notice there's a "throws Exception"...
the final java code snippet for test is :
input: begin dateTime
input: end dateTime
output: diff int, how many hours in (begin-end)
try{
System.out.println("\n\nTimeTestBegin");
String begin=getVariableData("begin").toString();
String end=getVariableData("end").toString();
System.out.println(begin+"-----"+end);
javax.xml.datatype.XMLGregorianCalendar beginTime = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(begin);
javax.xml.datatype.XMLGregorianCalendar endTime = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(end);
long diff=beginTime.toGregorianCalendar().getTimeInMillis()-endTime.toGregorianCalendar().getTimeInMillis();
setVariableData("diff",String.valueOf(diff/1000/3600));
System.out.println("DIFF======"+diff/1000/3600);
System.out.println("TimeTestEnd");
}catch(Exception e){
e.printStackTrace();
}

Similar Messages

  • How to calculate days between two DATES

    How to calculate days between two DATES ?
    which is the functional module for that ?
    help me

    Hi,
    use function module : it works,
    HR_HK_DIFF_BT_2_DATES
    give output format = 03 and get the value in days.
    code is as below :
    data : DATE1 type P0001-BEGDA,
    DATE2 type P0001-BEGDA,
    YEARS type P0347-SCRYY,
    MONTHS type P0347-SCRMM,
    DAYS type P0347-SCRDD.
    date1 = '20070331'.
    date2 = '20070101'.
    CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
    EXPORTING
    DATE1 = date1
    DATE2 = date2
    OUTPUT_FORMAT = '03'
    IMPORTING
    YEARS = years
    MONTHS = months
    DAYS = days
    EXCEPTIONS
    INVALID_DATES_SPECIFIED = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    write : days.
    Reward points, if helpful,
    Regards,
    Sandeep Kaushik

  • How to calculate variance between two dimension values

    Hello:
    I have built a cube in Analytical workspace (9.2.0.5) with 3 dimensions. Time, Product & Scenario. I am using BI Beans (thick client) for the presentation layer. What I need is the ability to calculate the variance between two dimension values of same measure. For example, if My scenarios are 'Actual' and 'Budget', when I present the results on the screen for any measure (e.g Total Sales), I should be able to calculate & display the difference between 'Actual' & 'Budget' values of that measure.
    I have more than 7 scenarios and more than 40 measures. It could even be the difference between two product categories. How do I do it either in AW or at BI Beans Level?
    Thank you very much for your help.
    regards
    Suresh

    You want to look at qualified data references in the OLAP DML references. Basically, any data reference may be qualified by specifying a dimension name and value:
    sales(time 'jan92')
    forces the dimension TIME to the member 'jan92', no matter whether 'jan92' is in status or not. The resulting expression is essentially no longer dimensioned by the dimension TIME.

  • How to Calculate second between two dates?

    I'm wish to create a ref ID using seconds between two dates as the uniue number. I usually use DateDiff function in VB to calculate the ref ID. But now instead developing using VB, i'm using java in developing my project. I wonder is there any class similar to the datediff function? Please advice.Thank you

    diff_sec =( Date1.getSeconds() - Date2.getSeconds());

  • Calculate difference between two dates/times

    Hi all,
    Is there any function module to calculate difference between two dates/times which are in TIMESTAMPL format.
    I need to know how many millisconde(second,minutes, hours... )there is between these two times.
    Please, It is urgent
    Thank you all.
    Karim

    hi,
    try the following function
    CALL FUNCTION 'CCU_TIMESTAMP_DIFFERENCE'        
          EXPORTING                                  
               timestamp1 = timestamp1               
               timestamp2 = timestamp2               
          IMPORTING                                  
               difference = diff                     
          EXCEPTIONS                                 
               OTHERS     = 1. 
    the above function gives the difference in seconds...
    try the following  code to set the resolution to milliseconds..
    SET RUN TIME CLOCK RESOLUTION LOW
    check the thread for details:
    SET RUN TIME CLOCK RESOLUTION?
    all the best!!!
    Regards,
    Aparna

  • Get number of hours between two dates and two hours using factory calendar

    Hello all,
    I have the following requirement: I need to calculate the number of hours between two dates and two hours (start date- finish date and start hour-finish hour) or timestamps using a factory calendar. I must program it on CRM environment.
    Does anybody know a function module that makes it?
    Thanks in advance.
    Carmen

    Please check function module DURATION_DETERMINE.
    - April King

  • How to configure connectivity between two vm linux hosts

    Hello All,
    i have installed vm workstation with two RHEL4 linux installation.
    Node 1:RHEL4
    Node 2:RHEL4
    i have configured 2 ethernet cards am able to ping in a host but not each other.
    i have tried to ping from Node 1 to Node 2 am getting icmp_seq=0 Destination Host Unreachable .....
    kindly suggest how to configure connectivity between two host permanently.please explain with example if possible. or suggest any link.
    thanks,
    Mike.

    1003614 wrote:
    thanks for quick reply ....Oracle vm workstation 4.2 am using.
    ... then your post is now moved to the appropriate forum space for your question (Oracle VM for x86).

  • How to get relationship between two  views in the  reports

    How to get relationship between two  views in the  reports, I am doing a deletion program , it is fully relates to views , how to get relationship between them in the reports

    Hi,
    Please explain your question in detail...what do you want to read ?
    If you want to know about the navigation links between the views then you can use APIs  like
    wdComponentAPI.getComponentInfo().findInWindows("windowName").getViewUsageByID("Name").getNavigationLinks();
    Iterate through the navigationLinkInfo from above collection and can read the other properties .
    I haven't tried the above , but it should work !!!
    Regards,Anilkumar

  • How can we navigate between two windows of same component in webdynpro ABAP

    Hi
    how can we navigate between two windows( not views ) of same component in webdynpro ABAP. its an urgent requirement
    Thanks in advance.
    Regards
    Laeeq

    Hi Laeeq,
    You cannot navigate between windows of one component. You can only call a dialog box showing the contents of a second window, or you can embed the contents of a window of a different component.
    Just add all the views you need to the one and only main window of the component.
    Ciao, Regina

  • In jsp file, how to transfer parameter between two javabean?

    In jsp file, how to transfer parameter between two javabean?
    for example
    Bean1 has a attribute A
    Bean2 has a attribute B
    how to transfer the value of A to B

    Have you tried something like...
    <jsp:setProperty name="Bean2" property="B" value="<jsp:getProperty name="Bean1" property="A" />" />

  • How to get space between two values in a single cell of a table.

    hello,
            how to get space between two values in a single cell of a table.
    thanks a lot.
    kailash.

    sorry i got the answer.

  • Inserting a node between two existing nodes not tworking!

    According to the user manual, I should be able to insert a node between two other nodes by dragging and dropping when the input knot is highlighted. I have never been able to get this to work. Anyone have any suggestions??

    FYI:
    http://discussions.apple.com/help.jspa#answers
    Patrick

  • How to check differences between two bpel jar files

    Hi,
    Can some one please suggest, how to check the differences between two versions of a BPEL process jar files.
    Thanks in advance!

    Hi,
    Try this,
    SELECT   cons.owner AS child_owner, cons.table_name AS child_table,
             cons.constraint_name constaint_name,
             cons.constraint_type constraint_type, col.owner parent_owner,
             col.table_name parent_table, col.column_name column_name
        FROM dba_cons_columns col, dba_constraints cons
       WHERE cons.r_owner = col.owner
         AND cons.r_constraint_name = col.constraint_name
         AND col.owner = 'MY_USER'
    ORDER BY child_table;Thanks,
    Shankar

  • How to caluclate tat between two dates of one timestamp field

    Hi,
    could some one help how to caluclate days between two dates of single timestamp filed and with this
    query
    Select * from m_activity_transaction where actn_opp_id in (
    Select actn_opp_id from m_activity_transaction where ACTN_ACTV_ID = 218
    Group by actn_opp_id
    having count(*) > 1 ) and ACTN_ACTV_ID = 218
    order by actn_performed_on
    iam getting output is
    ACTN_ID ACTN_OPP_ID ACTN_PERFORMED_ON
    319415 95831 27-JAN-12 11.06.20.000000 AM
    315249 95831 08-FEB-12 05.32.54.000000 PM
    301927 103509 20-DEC-11 04.01.43.000000 PM
    301458 103509 19-DEC-11 04.51.03.000000 PM
    294841 115840 10-JAN-12 03.20.12.000000 PM
    312062 115840 11-JAN-12 05.17.06.000000 PM
    and i nedd to caluclate no.of days between two dates like 27-JAN-12 11.06.20.000000 AM and 08-FEB-12 05.32.54.000000 PM where actn_id is unique AND ACTN_OPP_ID IS NOT UNIQUE.
    Thanks in Advance,
    vvr.

    This way?
    with data as
    select 315249 a, 95831 b, to_timestamp('27-JAN-12 11.06.20.000000 AM', 'DD-MON-RR HH.MI.SS.FF6 AM') dt from dual union all
    select 319415, 95831, to_timestamp('08-FEB-12 05.32.54.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 301927, 103509 , to_timestamp('20-DEC-11 04.51.03.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 301458 , 103509 , to_timestamp('19-DEC-11 04.01.43.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 363810 , 144656 , to_timestamp('27-JUN-12 12.43.28.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 363500 , 144656 , to_timestamp('26-JUN-12 11.41.50.000000 AM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 363354 , 144656 , to_timestamp('25-JUN-12 12.41.13.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual
    select a, b, diff
      from (
            select a, b, extract( day from (dt - lag(dt) over (partition by b order by dt, a)) ) diff
              from data
           ) tab
    where tab.diff is not null;
    A                      B                      DIFF                  
    319415                 95831                  12                    
    301927                 103509                 1                     
    363500                 144656                 0                     
    363810                 144656                 1

  • How to check similarity between two Databases 9i & 10g after imp in 10g

    Dear all,
    Source
    =======
    OS server     ==>     HP-UX
    Oracle version     ==>     Oracle 9.2.0.8
    DB Name          ==>     MSST
    DB total users     ==>     320
    Full export in     ==>     /u02/export/Jan09.dmp
    Tablespaces     ==>     SC, SC_I, SA, SA_I, PP, PP_I, AC, AC_I, SD
    Destination
    ============
    OS server          ==>     HP-UX
    DB Name               ==>     CHDB
    Existg DB users          ==>     20
    Oracle version          ==>     Oracle 10.2.0.4
    copied 9i dump file in     ==>     /u03/export
    Tablespaces created same as Oracle 9i i.e;          
    Tablespaces     ==>     SC, SC_I, SA, SA_I, PP, PP_I, AC, AC_I, SD
    I had run full import on Destination server i.e; Oracle 10g & following is the command i used:
    imp system/pwd@conn_string file=/u03/export/Jan09.dmp log=/u03/export/Jan09_imp.log full=y ignore=y statistics=none
    *=== Imported successfully with few errors like ====*
    IMP-00017: following statement failed with ORACLE error 2299:
    "ALTER TABLE "EMP_PROMOTIONS_ORD" ADD CONSTRAINT "EMP_PROMOTIONS_ORD_UK" UN"
    "IQUE ("EMP_NO", "RANK_NO_FOLLOW") USING INDEX PCTFREE 10 INITRANS 2 MAXTRAN"
    "S 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "PP" "
    "LOGGING ENABLE "
    IMP-00003: ORACLE error 2299 encountered
    ORA-02299: cannot validate (PP.EMP_PROMOTIONS_ORD_UK) - duplicate keys found
    ORA-02299: cannot validate (PP.EMP_PROMOTIONS_ORD_UK) - duplicate keys found
    . . importing table "EMP_PROMOTION_DETAILS" 13333 rows imported
    . . importing table "EMP_PROMOTION_MAST" 725 rows imported
    . . importing table "EMP_PUNISHMENT" 271 rows imported
    . . importing table "EMP_REPORT_BOOKS" 60528 rows imported
    . . importing table "EMP_SALARY_HISTORIES" 120871 rows imported
    . . importing table "EMP_SALARY_HISTORIES_TEMP" 77044 rows imported
    . . importing table "EMP_TRANSACTIONS" 96536 rows imported
    IMP-00017: following statement failed with ORACLE error 2299:
    "ALTER TABLE "EMP_TRANSACTIONS" ADD CONSTRAINT "TRANS_UK" UNIQUE ("EMP_NO","
    " "DIR_NO", "DIR_DATE", "TRN_CODE") USING INDEX PCTFREE 10 INITRANS 2 MAXTRA"
    "NS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "PP_"
    "I" NOLOGGING ENABLE "
    IMP-00003: ORACLE error 2299 encountered
    ORA-02299: cannot validate (PP.TRANS_UK) - duplicate keys found
    Now my question is
    ===================
    How to check everything is same/similar like Oracle 9i database ( source ), for example ( i used this technique ):
    Can anyone tell me how to check similarity between two Databases 9i & 10g after import in 10g.
    MSST_DB>SHOW USER
    MSST_DB>SA
    MSST_DB>select object_type, count(*) from user_objects group by objects;
    OBJECT_TYPE     COUNT(*)
    DATABASE LINK     2
    FUNCTION     23
    INDEX          1795
    LOB          6
    PACKAGE          8
    PACKAGE BODY     8
    PROCEDURE     30
    SEQUENCE     67
    SYNONYM          60
    TABLE          644
    TRIGGER          3
    VIEW          20
    CHDB_DB>SHOW USER
    CHDB_DB>SA
    CHDB_DB>select object_type, count(*) from user_objects group by objects;
    OBJECT_TYPE     COUNT(*)
    INDEX          1794
    PROCEDURE     30
    TABLE          644
    TRIGGER          3
    VIEW          20
    FUNCTION     23
    SYNONYM          60
    PACKAGE BODY     8
    SEQUENCE     67
    PACKAGE          8
    LOB          6
    Edited by: VIKHARAHMED on Jan 10, 2012 3:02 AM

    [url http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/dp_export.htm#sthref67]Guide.

Maybe you are looking for

  • Report Generation Toolkit labview 2013 64bits?

    Muy buenas tardes. Estoy buscando el Report Generation Toolkit para labview 2013 64bits, lo he buscado pero no logro encontrarlo y con este mismo pero de 32 bits me marca error al instalarlo.

  • RFC to JDBC Scenario

    Hi, I am trying a syncronous RFC to JBDC scenario wherein i send data to JDBC tables and i response i m gettin the count of number of records that are inserted The scenario works fine if i try to Insert a new record. But when i send the same records

  • Report file not found error

    We recently upgraded from JBoss 4.2 to JBoss 5.1.  Our Crystal reports were working fine in JBoss 4.2, but we've had several issues in 5.1.  after resolving several issues, I have reached a point where the application iis unable to locate the .rpt fi

  • Deploying Forms

    I am a newbie to Forms development. I have Forms Builder downloaded, also WebLogic Server. Oracle Classic 11g and Oracle Fusion Middleware 11.1.1.2.0 I have WLS_FORMS started and I can access the Weblogic admin and EM applications. I have left the We

  • (fn+F2 and fn+F3) for brightness are not working

    (fn+F2 and fn+F3) for brightness are not working, while the other function working properly... help me plz DJanoon