Mediator - convert XSD datetime to SQL date value

Fusion 11g, JDev 11.1.1, W server 2008
Hi there,
using JDev we've defined a DB adapter (towards an ORACLE schema), which basically serves two operations: INSERT and SELECT. On the DB table we've got a DATE_TIME while on on the other side we've defined a wsdl where the INPUT operation takes as parameter an XSD DATETIME value.
The values have different structures and so we've started to play with the "Assign Values" function on the Mediator component, unfortunately without any success.
Right now our expression is the following
from
ora:formatDate($in.newEventParam/newEventParam/ns:executionTime,"dd-MMM-yy")
to
$out.LogCollection/top:LogCollection/top:Log/top:when
As first question I would like to ask you if our approach is correct and in that case what's wrong with our expression as we tried to use the same pattern as we use in SQL.
Second, we performed some tests using the EM console. On test failure it shown a stack trace saying only that there was a problem performing a transformation. That's a bit too less, especially when transformation is done on large amount of values. Is there any way to increase trace level and get further details on which transformation didn't work out?
Thanks in advance
Alessandro Ilardo

Thanks Eric for the link. That helped me to get further details about the issue but unfortunately not enough to locate the cause.
So here I definitely have an issue with the composite application and perhaps another one on getting a SOAP trace from the Mediator log. Even with the finest log level enabled I couldn't see what the Mediator receives from outside.
The first problem instead, seams to be a missing SOAP parameter, I assume that's why on the log I see this
[WEBSERVICE.name: AuditService] [J2EE_APP.name: soa-infra] [composite_instance_id: 40011] Transformation failed[[
oracle.tip.mediator.infra.exception.MediatorException: ORAMED-01203:[No Part]No part exist with name "newEventParam" in source message.Possible Fix:Review the transformation definition in mplan.Contact Oracle Support if the error cannot be fixed.
     at oracle.tip.mediator.service.transformation.XSLTransformer.getPartDocument(XSLTransformer.java:221)
[J2EE_APP.name: soa-infra] [composite_instance_id: 40011] Got an exception: java.lang.NullPointerException[[
oracle.tip.mediator.infra.exception.MediatorException: ORAMED-01201:[Error in transform operation]Error occurred while transforming payload.Possible Fix:Review the XSL or source payload. Either the XSL defined does not match with the payload or payload is invalid.
In this routing there are basically 2 things that take place, an XSL mapping and an Assign value expression.
Everything is goes fine until we perform a test from the EM, there we get the error.
Unless someone has further tips on this issue I am considering to make a call from SOAPUI and place WS Monitor in the middle to make sure if the mistake is in the application or platform.
External WSDL
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://xml.virtual-lab.eu/schema/poc-soa/audit/wsdl" xmlns:ns="http://xml.virtual-lab.eu/schema/poc-soa/audit/def" targetNamespace="http://xml.virtual-lab.eu/schema/poc-soa/audit/wsdl">
     <wsdl:types>
          <schema xmlns="http://www.w3.org/2001/XMLSchema">
               <import namespace="http://xml.virtual-lab.eu/schema/poc-soa/audit/def" schemaLocation="xsd/AuditParamsDef.xsd"/>
          </schema>
     </wsdl:types>
     <wsdl:message name="addNewRequestMessage">
          <wsdl:part name="newEventParam" type="ns:add"/>
     </wsdl:message>
     <wsdl:message name="searchRequestMessage">
          <wsdl:part name="searchParams" type="ns:search"/>
     </wsdl:message>
     <wsdl:message name="searchResponseMessage">
          <wsdl:part name="returnParam" type="ns:eventObj"/>
     </wsdl:message>
     <wsdl:portType name="AuditPortType">
          <wsdl:operation name="addNewEvent">
               <wsdl:input message="tns:addNewRequestMessage"/>
          </wsdl:operation>
          <wsdl:operation name="searchForEvents">
               <wsdl:input message="tns:searchRequestMessage"/>
               <wsdl:output message="tns:searchResponseMessage"/>
          </wsdl:operation>
     </wsdl:portType>
     <wsdl:binding name="AuditBinding" type="tns:AuditPortType">
          <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
          <wsdl:operation name="addNewEvent">
               <soap:operation soapAction="urn:#addNewEvent"/>
               <wsdl:input>
                    <soap:body use="literal"/>
               </wsdl:input>
          </wsdl:operation>
          <wsdl:operation name="searchForEvents">
               <soap:operation soapAction="urn:#searchForEvents"/>
               <wsdl:input>
                    <soap:body use="literal"/>
               </wsdl:input>
               <wsdl:output>
                    <soap:body use="literal"/>
               </wsdl:output>
          </wsdl:operation>
     </wsdl:binding>
     <!--
     <wsdl:service name="AuditService">
          <wsdl:port name="AuditPort" binding="tns:AuditBinding" />
     </wsdl:service>
-->
</wsdl:definitions>
XSL
<?xml version="1.0" encoding="UTF-8" ?>
<?oracle-xsl-mapper
<!-- SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY. -->
<mapSources>
<source type="WSDL">
<schema location="../AuditService.wsdl"/>
<rootElement name="newEventParam" namespace=""/>
<rootElementDatatype name="add" namespace="http://xml.virtual-lab.eu/schema/poc-soa/audit/def"/>
</source>
</mapSources>
<mapTargets>
<target type="WSDL">
<schema location="../AuditBackEndService.wsdl"/>
<rootElement name="LogCollection" namespace="http://xmlns.oracle.com/pcbpel/adapter/db/top/AuditBackEndService"/>
</target>
</mapTargets>
<!-- GENERATED BY ORACLE XSL MAPPER 11.1.1.0.0(build 090618.1440.5219) AT [WED DEC 02 22:51:43 CET 2009]. -->
?>
<xsl:stylesheet version="1.0"
xmlns:top="http://xmlns.oracle.com/pcbpel/adapter/db/top/AuditBackEndService"
xmlns:xpath20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/db/SOA-POC/AuditService/AuditBackEndService%2F"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:med="http://schemas.oracle.com/mediator/xpath"
xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
xmlns:ns="http://xml.virtual-lab.eu/schema/poc-soa/audit/def"
xmlns:xdk="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"
xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:ora="http://schemas.oracle.com/xpath/extension"
xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
exclude-result-prefixes="xsi xsl ns xsd top tns plt wsdl xpath20 bpws mhdr oraext dvm hwf med ids xdk xref ora socket">
<xsl:template match="/">
<top:LogCollection>
<top:Log>
<top:who>
<xsl:value-of select="/newEventParam/ns:fromUser"/>
</top:who>
<top:when/>
<top:whichClient>
<xsl:value-of select="/newEventParam/ns:usingClient"/>
</top:whichClient>
<top:whichSys>
<xsl:value-of select="/newEventParam/ns:onSys/@ns:which"/>
</top:whichSys>
<top:ipClient>
<xsl:value-of select="/newEventParam/ns:fromIP"/>
</top:ipClient>
<top:wsOperation>
<xsl:value-of select="/newEventParam/ns:callingWS_Operation"/>
</top:wsOperation>
</top:Log>
</top:LogCollection>
</xsl:template>
</xsl:stylesheet>
Internal WSDL
<?xml version="1.0" encoding="UTF-8"?>
<toplink:object-persistence version="Oracle TopLink - 11g Release 1 (11.1.1.1.0) (Build 090527)" xmlns:opm="http://xmlns.oracle.com/ias/xsds/opm" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:toplink="http://xmlns.oracle.com/ias/xsds/toplink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<opm:name>AuditBackEndService-OR</opm:name>
<opm:class-mapping-descriptors>
<opm:class-mapping-descriptor xsi:type="toplink:object-relational-class-mapping-descriptor">
<opm:class>AuditBackEndService.Log</opm:class>
<opm:alias>LOG</opm:alias>
<opm:primary-key>
<opm:field table="LOG" name="ID" xsi:type="opm:column"/>
</opm:primary-key>
<opm:events xsi:type="toplink:event-policy"/>
<opm:querying xsi:type="toplink:query-policy">
<opm:queries>
<opm:query name="AuditBackEndServiceSelect" xsi:type="toplink:read-all-query">
<opm:criteria operator="and" xsi:type="toplink:logic-expression">
<toplink:left operator="and" xsi:type="toplink:logic-expression">
<toplink:left operator="equal" xsi:type="toplink:relation-expression">
<toplink:left name="whichSys" xsi:type="toplink:query-key-expression">
<toplink:base xsi:type="toplink:base-expression"/>
</toplink:left>
<toplink:right xsi:type="toplink:parameter-expression">
<toplink:parameter name="sys" xsi:type="opm:column"/>
</toplink:right>
</toplink:left>
<toplink:right operator="greaterThanEqual" xsi:type="toplink:relation-expression">
<toplink:left name="when" xsi:type="toplink:query-key-expression">
<toplink:base xsi:type="toplink:base-expression"/>
</toplink:left>
<toplink:right xsi:type="toplink:parameter-expression">
<toplink:parameter name="fromWhen" xsi:type="opm:column"/>
</toplink:right>
</toplink:right>
</toplink:left>
<toplink:right operator="lessThanEqual" xsi:type="toplink:relation-expression">
<toplink:left name="when" xsi:type="toplink:query-key-expression">
<toplink:base xsi:type="toplink:base-expression"/>
</toplink:left>
<toplink:right xsi:type="toplink:parameter-expression">
<toplink:parameter name="toWhen" xsi:type="opm:column"/>
</toplink:right>
</toplink:right>
</opm:criteria>
<opm:arguments>
<opm:argument name="sys">
<opm:type>java.lang.String</opm:type>
</opm:argument>
<opm:argument name="fromWhen">
<opm:type>java.lang.String</opm:type>
</opm:argument>
<opm:argument name="toWhen">
<opm:type>java.lang.String</opm:type>
</opm:argument>
</opm:arguments>
<toplink:reference-class>AuditBackEndService.Log</toplink:reference-class>
<toplink:container xsi:type="toplink:list-container-policy">
<toplink:collection-type>java.util.Vector</toplink:collection-type>
</toplink:container>
</opm:query>
</opm:queries>
</opm:querying>
<opm:attribute-mappings>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>id</opm:attribute-name>
<opm:field table="LOG" name="ID" xsi:type="opm:column"/>
<toplink:attribute-classification>java.math.BigDecimal</toplink:attribute-classification>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>who</opm:attribute-name>
<opm:field table="LOG" name="WHO" xsi:type="opm:column"/>
<toplink:attribute-classification>java.lang.String</toplink:attribute-classification>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>when</opm:attribute-name>
<opm:field table="LOG" name="WHEN" xsi:type="opm:column"/>
<toplink:attribute-classification>java.sql.Timestamp</toplink:attribute-classification>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>whichClient</opm:attribute-name>
<opm:field table="LOG" name="WHICH_CLIENT" xsi:type="opm:column"/>
<toplink:attribute-classification>java.lang.String</toplink:attribute-classification>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>whichSys</opm:attribute-name>
<opm:field table="LOG" name="WHICH_SYS" xsi:type="opm:column"/>
<toplink:attribute-classification>java.lang.String</toplink:attribute-classification>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>ipClient</opm:attribute-name>
<opm:field table="LOG" name="IP_CLIENT" xsi:type="opm:column"/>
<toplink:attribute-classification>java.lang.String</toplink:attribute-classification>
</opm:attribute-mapping>
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>wsOperation</opm:attribute-name>
<opm:field table="LOG" name="WS_OPERATION" xsi:type="opm:column"/>
<toplink:attribute-classification>java.lang.String</toplink:attribute-classification>
</opm:attribute-mapping>
</opm:attribute-mappings>
<toplink:descriptor-type>independent</toplink:descriptor-type>
<toplink:caching>
<toplink:cache-type>weak-reference</toplink:cache-type>
<toplink:always-refresh>true</toplink:always-refresh>
</toplink:caching>
<toplink:remote-caching>
<toplink:cache-type>weak-reference</toplink:cache-type>
</toplink:remote-caching>
<toplink:instantiation/>
<toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
<toplink:tables>
<toplink:table name="LOG"/>
</toplink:tables>
<toplink:structure>structureName</toplink:structure>
</opm:class-mapping-descriptor>
</opm:class-mapping-descriptors>
<toplink:login xsi:type="toplink:database-login">
<toplink:platform-class>oracle.toplink.platform.database.oracle.Oracle9Platform</toplink:platform-class>
<toplink:user-name></toplink:user-name>
<toplink:connection-url>null</toplink:connection-url>
</toplink:login>
</toplink:object-persistence>

Similar Messages

  • Convert Calendar to Java.sql.Date

    I seached for a solution for converting a Calendar-object to a java.sql.date for inserting it into a MySQL DB (DateTime). I know this question is a FAQ. The solution I found is the following code:
    java.sql.Date sqlDate =  new java.sql.Date(cal.getTime().getTime() );When i do a print of the sqlDate to the console I get: sqlDate: 2005-06-27
    But when I look into de DB I get the following date: 27/05/1905
    I know that in Java the months are starting from 0-�11 and that the years counting is starting from 1900. But I assume that the solution is not to just add the correct month and year manually. because I get a correct console-output. If I do this I get a correct DB Date, but a wrong console-date.

    II dont know if you found an answer but I needed a similar solution so I wrote a test program.
    Let me know if this solves the problem for you.
    import java.util.*;
    import java.sql.*;
    public class dateTest{
    public static void main(String args[]){
    // Step by step
    // Calendar rightNow = Calendar.getInstance();
    // java.util.Date today = rightNow.getTime();
    // long theTime = today.getTime();
    // java.sql.Date sDate = new java.sql.Date(theTime);
    // In one line
    java.sql.Date sDate = new java.sql.Date(Calendar.getInstance().getTime().getTime());
    System.out.println("sDate is: "+sDate.toString());
    }

  • Convert string into java.sql.Date

    Hi,
    I want to convert a date in string form into java.sql.Date to persist into the database column with Date as its datatype in Oracle. I'm trying as follows:
    import java.sql.Date;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    public class DateTest
    public static void main(String[] args)
    String strDate = "2002-07-16 14:45:01";
         System.out.println("strDate = "+strDate);
    Date aDate = null;
    try
    if(strDate != null && !strDate.trim().equals(""))
         SimpleDateFormat aSDF = new SimpleDateFormat();
         aSDF.applyPattern("yyyy-MM-dd hh:mm:ss");
         java.util.Date utilDate = aSDF.parse(strDate);
    System.out.println("utildate = "+utilDate);
         aDate = new Date(utilDate.getTime());
         aDate.setTime(utilDate.getTime());      
         System.out.println("aDate = "+aDate);
    catch (ParseException e)
    System.out.println("Unable to parse the date - "+strDate);
    catch (Exception ex)
    ex.printStackTrace();
    System.out.println("Caught Exception :"+ex.getMessage());
    It gives the output as :
    strDate = 2002-07-16 14:45:01
    utildate = Tue Jul 16 14:45:01 IST 2002
    aDate = 2002-07-16
    If I put this value into the database table, I can see only the date. Time part is missing. Is this the problem with java.sql.Date or Oracle datatype Date? Please help me asap.
    Thanks in advance.
    Regards,
    Rajapriya.R.

    If I put this value into the database table, I can
    see only the date. Time part is missing. Is this the
    problem with java.sql.Date or Oracle datatype Date?This is not a problem, this is the defined behaviour of the Date type. RTFAPI and have a look at Timestamp, while you're at it.

  • Needed help regarding converting  string to java.sql.Date format

    I have a a function which returns a calendar object. The date must be inserted to Oracle DB using java.sql.Date format.
    So i have converted the Calendar object to java.sql.Date format using the following code
    java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());But while getting inserted into the DB it was in mm/dd/yyyy format whereas i wanted dd/mm/yyyy format
    Can any body please help out how to store the date in dd/mm/yyyy format ?

    Can u please explain this a bit
    This is my code
    public int addBook(List<Book> BookList) throws SQLException, ParseException{
              System.out.println("Hi there");
              Book book = new Book();
              BookDB bookDb = new BookDB();
              //listLength =      BookList.length;
              String bookId = null;
                   try{
                        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                        con  = DriverManager.getConnection("jdbc:oracle:thin:@10.123.79.195:1521:findb01","e115314", "e115314");
                        addBook = con.prepareStatement("insert into ABC_Book values(?,?,?,?,?,?,?)");
                        Iterator<Book> iterator = BookList.iterator();
                        while(iterator.hasNext()){
                             book = (Book)iterator.next();
                             System.out.println(book.getBookId());
                             addBook.setString(1,book.getBookId());
                             addBook.setString(2,book.getTitle());
                             addBook.setString(3,book.getAuthor());
                             addBook.setString(4,book.getPublisher());
                             System.out.println(book.getPublicationDate());
                             System.out.println("Before Date");
                             System.out.println("book.getPublicationDate().getTime()"+book.getPublicationDate().getTime());
                             java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());
                             SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy");
                             dateString = formatter.format(publicationDate);
                             System.out.println("Today is"+dateString);
                             java.sql.Date date = (java.sql.Date)formatter.parse(dateString);
                             System.out.println("date"+date);
                             //java.sql.Date publicationDate = (Date)book.getPublicationDate().getTime();
                             //System.out.println("Value of date is"+publicationDate);
                             System.out.println("After Date");
                             addBook.setDate(5,publicationDate);
                             addBook.setString(6,book.getCountry());
                             addBook.setString(7,book.getLanguage());
                             rs = addBook.executeQuery();
                             //con.commit();
                             rowCount = rowCount + rs.getRow();
                        return rowCount;
                   catch(SQLException se){
                        se.printStackTrace();
                   finally{
                        con.close();
                        System.out.println("After adding ");
              return 0;
         }

  • Trying to convert String to java.sql.Date

    I need to convert a String (in the format "yyyy-mm-dd") to java.sql.Date
    It was suggested I use the following,
    SimpleDateFormat formater = new SimpleDateFormat("yyyy-mm-dd");
    Date result = formater.parse(dbirth.getText());
    However, It seem to produce a java.util.Date
    Error: found java.util.Date
    Required : java.sql.Date
    Can anyone help?
    Thanks, Marika

    I need to convert a String (in the format
    "yyyy-mm-dd") to java.sql.Date
    It was suggested I use the following,
    SimpleDateFormat formater = new
    SimpleDateFormat("yyyy-mm-dd");
    Date result = formater.parse(dbirth.getText());
    However, It seem to produce a java.util.Date
    Error: found java.util.Date
    Required : java.sql.Date
    Can anyone help?
    Thanks, Marika SimpleDateFormat formater = new SimpleDateFormat("yyyy-mm-dd");
    java.util.Date parsedDate = formater.parse(dbirth.getText());
    java.sql.Date result = new java.sql.Date(parsedDate.getTime());

  • Convert xsd:dateTime to UTC

    Hello community,
    Within a message mapping I have to convert a field containing date, time and timezone to UTC/GMT timezone.
    Example:
    2008-10-06T01:11:06+02:00 = Incoming value from source field, incl. local time + time zone offset
    2008-10-05T23:11:06 = Expected value of target field, incl. UTC date and time
    How can I achieve this conversion with an UDF?
    Best regards,
    Wolfgang

    Hi,
    U can chabge the time zone of the calender ussing TimeZone java class .
    Try this UDF:
    Import : java.text.*;
    UDF:
    AbstractTrace trace = container.getTrace();
    String strDate =a;// "2008-10-06T01:11:06+0200";
              Date date=null;
              SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
              try{          
                   String dt = strDate;          
                   date = sdfSource.parse(dt);
                   trace.addInfo("NOW1:"+date);
                   //Time Zone
                   Calendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT+05:30"));
                   trace.addInfo("Current Timezone="+cal1.getTimeZone().getDisplayName());
                   String timeZoneId = "UTC";//Canada/Central";  // EX.
                   trace.addInfo("Getting Time in the timezone="+timeZoneId);
                   Calendar mbCal = new GregorianCalendar(TimeZone.getTimeZone(timeZoneId));
                   mbCal.setTimeInMillis(date.getTime());
                   Calendar cal = Calendar.getInstance();
                   cal.set(Calendar.YEAR, mbCal.get(Calendar.YEAR));
                   cal.set(Calendar.MONTH, mbCal.get(Calendar.MONTH));
                   cal.set(Calendar.DAY_OF_MONTH, mbCal.get(Calendar.DAY_OF_MONTH));
                   cal.set(Calendar.HOUR_OF_DAY, mbCal.get(Calendar.HOUR_OF_DAY));
                   cal.set(Calendar.MINUTE, mbCal.get(Calendar.MINUTE));
                   cal.set(Calendar.SECOND, mbCal.get(Calendar.SECOND));
                   cal.set(Calendar.MILLISECOND, mbCal.get(Calendar.MILLISECOND));
                   Date newdt =  cal.getTime();
                   trace.addInfo("Getting Time in the timezone=####"+newdt);
                   SimpleDateFormat sdfDestination = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
                   strDate = sdfDestination.format(newdt);
                   trace.addInfo("NOW3:"+strDate);
              }catch(ParseException pe){
                    trace.addInfo("Parse Exception : " + pe);
    return strDate;
    Regards
    Ritu

  • How to set a date value at netui:hidden/ tag bind to a RowSet item/property through a form bean?

    Hi,
    I have the following urgent problem.
    I created a pageflow which uses a form bean (created with a db control) to insert
    values in a table. I overcame the disability to insert date values in the table
    by converting this columns to string values in the table. But now I have to insert
    a sysdate in a column that holds the row sampled date. How is it possible? I used
    javascript without an success.
    Code in jsp:
    document[getNetuiTagName("myForm",this)][getNetuiTagName("date",this)].value=new
    Date();(have used string values too)
    <netui:hidden dataSource="{actionForm.sampled}" tagId="date"/>
    Code in .jcx file
    <xsd:element name="SAMPLED" type="xsd:dateTime" wld:JDBCType="DATE" minOccurs="0"
    wld:TableName="theTable" nillable="true">
    * </xsd:element>
    Code in .jpf file
    * <pageflow-object id="formbeanprop:portlets.Career.Submit_CV.Submit_CVController.DatabaseForm#sampled#java.sql.Timestamp"/>
    public static class DatabaseForm extends RowSetForm
    public java.sql.Timestamp getSampled()
    return sampled;
    public void setSampled(java.sql.Timestamp newOne)
    registerChange("sampled");
    this.sampled = newOne;
    I have tried to use java.sql.Date too...
    Any help would be very appreciated.
    Thx,
    Vincent

    Hi,
    Hope You're using the template.fmb.
    If  your Custom Form is in INV module, use  'FND_ORG.CHOOSE_ORG;' in the pre-form.
    Else Set the org id dynamically,
    begin
        MO_GLOBAL.SET_POLICY_CONTEXT(ACCESS_MODE,ORG_ID);
    end;
    Example:
    begin
        MO_GLOBAL.SET_POLICY_CONTEXT('S',101);
    end;
    S - Denotes that the current session will work for Single Org_id (101)
    M - Denotes that the current session will work for Multiple Org_id
    Thanks

  • Conversions between java.util.Date, java.util.Timestamp and java.sql dates

    I am coding a hoilday booking system using JSP to interact with a SQL Server database. On my JSP form which retrieves the information I have a little javascript pop-up date selector which appears to be returning a Timestamp value although the string value is visable in the entry field. Can I pass this to a javabean as a Timestamp, so far I have only passed strings? Also I then have to enter it in the database and so will need to convert it to an sql date type but I dont know which one is best. Previous to using the Timestamp returning calendar I was just entering text and parsing it to a util.Date in the bean and then converting that to an sql.Date for entry in the database. That worked fine but I want to use the pop-up any ideas? Also my bean won't compile if I declare java.util.Timestamp t;(cannot resolve symbol Timestamp !) even though I have imported util.

    First of all, java.util.Timestamp does not exist. You probably need java.sql.Timestamp.
    java.sql.Date and java.sql.Timestamp inherit from java.util.Date. So converting from java.sql.Date or java.sql.Timestamp to java.util.Date is easy, you don't have to do anything.
    To convert a java.util.Date to a java.sql.Timestamp, do something like this:
    import java.sql.Timestamp;
    import java.util.Date;
    Date date = new Date();
    Timestamp ts = new Timestamp(date.getTime());Jesper

  • Prepared statement - setDate(index, sql.Date, Cal) Help!

    Hi everyone, I'm creating a form to query an Oracle table. I'm setting up the search criteria which includes a start and end date. (in this example I've just used the start date)
    I get all the search parameters into my JSP and I created the following Calendar objects:
    // Calendar creation
    Calendar startCal = Calendar.getInstance();
    startCal.set(start_year, start_month, start_day, start_hour, start_minute);
    Calendar endCal = Calendar.getInstance();
    endCal.set(end_year, end_month, end_day, end_hour, end_minute);
    //define a sql.Date value for start and end date
    java.sql.Date startDate = null;
    java.sql.Date endDate = null;I then create a string that contains my SQL statement:
    String sqlStmt = "select dateValue, value3 from someTable where dateValue >= ? and value2 = ?";In my Prepared Statement I pass in the following information:
    ps = c.prepareStatement(sqlStmt);
    ps.setDate(1, startDate, startCal);
    ps.setString(2, searchValue);My question is the following - I define the hour and minute in my Cal object - will that information get passed into my "startDate" sql.Date object? According to the API it should work (at least that's my understading of it):
    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html#setDate(int,%20java.sql.Date,%20java.util.Calendar)
    My search does not blow up or report any errors but it never finds a match - even when I put in parameters that I know are a match.
    Any feedback is appreciated.

    I think I got it. my java.sql.Date can't be null.
    java.sql.Date startDate = null;
    java.sql.Date endDate = null;needs to be:
    java.util.Date startCalendarDate = startCal.getTime();
    java.util.Date endCalendarDate = endCal.getTime();
    java.sql.Date startDate = new java.sql.Date(startCalendarDate.getTime());
    java.sql.Date endDate = new java.sql.Date(endCalendarDate.getTime());

  • (Again) java.util.Date vs java.sql.Date

    Hi there,
    (Again) Im trying to understand the EXACT difference between
    java.util.Date vs java.sql.Date.
    Googling, I can see that this is a very "popular" subject, but I still
    cannot figure out it exactly.
    Many writers claim that java.sql.Date only stores the DATE part (yyyy-
    mm-dd) but not the TIME part (hh:MM:ss) of a Date/Time value, but that
    I can easily disprove:
                    java.util.Date ud = new java.util.Date();                 java.sql.Date sd = new java.sql.Date(ud.getTime());                 System.out.println(DateFormatUtils.                                 format(ud, "yyyy-MM-dd HH:mm:ss.SSS"));                 System.out.println(DateFormatUtils.                                 format(sd, "yyyy-MM-dd HH:mm:ss.SSS"));
    Output:
                    2009-09-18 15:17:36.635                 2009-09-18 15:17:36.635
    So, apparently, java.sql.Date and java.util.Date have THE SAME
    precision (at least down to the millisecs...).
    And the official API documentation, really looks more confusing than
    helpful to me::
    *"java.sql.Date:*
    *A thin wrapper around a millisecond value that allows JDBC to identify*
    *this as an SQL DATE value. A milliseconds value represents the*
    *number of milliseconds that have passed since January 1, 1970*
    *00:00:00.000 GMT.*
    *To conform with the definition of SQL DATE, the millisecond values*
    *wrapped by a java.sql.Date instance must be 'normalized' by setting*
    *the hours, minutes, seconds, and milliseconds to zero in the*
    *particular time zone with which the instance is associated. "*
    Exactly what means "an SQL DATE value" ? How EXACTLY does it differ
    from a java.util.Date value?
    Most importantly: WHY does JDBC need to distinguish between them?
    And, here again: *"a java.sql.Date instance must be 'normalized' by*
    *setting the hours, minutes, seconds, and milliseconds to zero in the*
    *particular time zone..."*
    What does that mean exactly? Apparently, the constructor doesnt
    enforce this restriction, per the example above. So what's the REAL
    point with this type, java.sql.Date?
    Very greatful, if you can help me clarify this, once and for all.
    TIA,

    And the official API documentation, really looks more confusing than helpful to me:The problem is that you need to understand SQL as well as Java for this to make sense. It's not the Java API's job to tell you how your SQL database works - there's a myriad of subtle differences even when the DB is compliant with the SQL spec.
    Most compliant databases support DATE, TIME, and TIMESTAMP values. DATE represents only a date. TIME represents only a time. TIMESTAMP represents both. There are further complicating factors, but that's roughly how it stands.
    In Java the normal type for representing time is (or was when the API was created) the java.util.Date but this is a close approximation only to the TIMESTAMP value. In order to bring the two together the java.sql.Date, java.sql.Time and java.sql.Timestamp classes were created. Making them derive from java.util.Date was probably not a good idea.
    java.util.Date suffers from a number of deficiencies. java.util.Calendar was supposed to address them but didn't really succeed. The JodaTime library is rather better, but it's all a lot more complicated than you might expect - partly because time management really is a much harder problem than it appears at first glance - there are timezones, leap years, leap seconds, the difference between astronomical and atomic time, and so on and so forth.

  • How to convert a date value into week value?

    How to display the date value like '20010203'
    into the week number of the year 2001?
    When i type in the following sql
    select week(chg_time) from site;
    I got this error message
    ORA-00904: invalid column name

    use the to_char function, to format the date into a week number (then you might need to convert that to a number using to_number)
    select to_char( sysdate, 'WW') from dual`
    a description of datetime formats: http://download-west.oracle.com/otndoc/oracle9i/901_doc/server.901/a90125/sql_elements4.htm#48515

  • Not able to convert element of type xs:date to dateTime in XSLT 2.0

    Hi,
    I am trying to subtract 2 dates and get the month difference between the two using XSLT 2.0
    This is what I have done
    <xsl:variable name="monthDiff">
    <xsl:call-template name="monthDifference">
    <xsl:with-param name="date1" select="/tns:StartDate"/>
    <xsl:with-param name="date2" select="xp20:current-dateTime()"/>
    </xsl:call-template>
    Template
    <xsl:template name="monthDifference">
    <xsl:param name="date1"/>
    <xsl:param name="date2"/>
    <xsl:value-of select="(xsd:dateTime($date1) - xsd:dateTime($date2))"/>
    </xsl:template>
    Problem I am facing is
    1. If the value of tns:StartDate is in below format then this transformation works successfully
    2012-08-31T10:00:37+05:30
    2. But I am getting tns:StartDate as input in the below format due to which the transformation fails
    2012-08-31-04:00
    I tried formatting the date in required format but still the transformation fails
    Can someone please help in solving this issue..
    Thanks in Advance.
    Thanks,
    Anju
    Edited by: Anju on Aug 29, 2012 11:10 PM

    Hi Anju,
    Try this...
              <xsl:variable name="monthDiff">
                   <xsl:call-template name="monthDifference">
                        <xsl:with-param name="date1" select="/tns:StartDate"/>
                        <xsl:with-param name="date2" select="xp20:current-date()"/>
                   </xsl:call-template>
              </xsl:variable>
         <xsl:template name="monthDifference">
              <xsl:param name="date1"/>
              <xsl:param name="date2"/>
              <xsl:value-of select="(xsd:date($date1) - xsd:date($date2))"/>
         </xsl:template>Cheers,
    Vlad

  • How to convert epoch time to datetime in sql*loader Oracle

    Hello,
    I wan't to question how to convert epoch time to datetime in sql*loader Oracle. I try this script for convert epoch time to datetime in sql*loader, but error:
    Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
    ORA-01722: invalid number
    Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
    ORA-01722: invalid number
    Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
    ORA-01722: invalid number
    This is my loader:
    LOAD DATA INFILE 'C:\Documents and Settings\Administrator\My Documents\XL_EXTRACT_211\load.csv'
    into table TEMP_TEST_LANGY append
    FIELDS TERMINATED BY ','
    TRAILING NULLCOLS
    DATADATA CHAR "TO_DATE('01-JAN-1970','DD-MON-YYYY')+:datadata/86400"
    This is my csv file:
    79314313.7066667
    79314336.2933333
    79314214.3466667
    This is my table:
    CREATE TABLE TEMP_TEST_LANGY
    DATADATA DATE
    Thanks
    Edited by: xoops on Sep 21, 2011 8:56 AM
    Edited by: xoops on Sep 21, 2011 8:58 AM

    thanks for your answer, but I asked to use sql loader instead of the external table, which so my question is why can not the epochtime converted to datetime, if there is no way to convert a datetime epochtime using sql loader, so I'm required to use the external table. thank you.
    This is my error log:
    Column Name Position Len Term Encl Datatype
    DATADATA FIRST * , CHARACTER
    SQL string for column : "TO_DATE('1-Jan-1970 00:00:00','dd-MM-YYYY hh24:mi:ss') + (:DATADATA/60/60/24)"
    Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
    ORA-01722: invalid number
    Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
    ORA-01722: invalid number
    Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
    ORA-01722: invalid number
    Edited by: xoops on Sep 21, 2011 12:33 PM

  • How to convert JAVA.SQL.DATE date in YYYY/MM/DD format into DD/MM/YYYY

    i am using informix database which accepts date value in the form of DATE format......
    the other part of my application takes date from the field in DD/MM/YYYY format...so i have to convert my java.sql.date in YYYY/MM/DD fromat into DD/MM/YYYY fromat of same type before inserting into db......
    but using parse method in SimpleDateFormat class can get the result only in java.util.date format...
    and also using format method can result only in string conversion........

    816399 wrote:
    i am using informix database which accepts date value in the form of DATE format......Huh?
    Maybe you mean Informix (fronted by JDBC) expects date values as java.sql.Date objects?
    the other part of my application takes date from the field in DD/MM/YYYY format...
    so i have to convert my java.sql.date in YYYY/MM/DD format into DD/MM/YYYY format of same type before inserting into db......I am not sure why you are talking about formats here.
    There is no formatting inherent in a java.util.Date object
    nor in a java.sql.Date object.
    but using parse method in SimpleDateFormat class can get the result only in java.util.date format...
    and also using format method can result only in string conversion........You can easily create a java.sql.Date object from a java.util.Date object.
    String s = "31/12/2010";
    java.util.Date ud = new java.text.SimpleDateFormat("dd/MM/yyyy").parse(s);
    java.sql.Date sd = new java.sql.Date(ud.getTime());
    ud = sd; // java.sql.Date extends java.util.Date so no conversion is needed

  • Can I convert Facebook time Text to Project Siena's Date value ?

    Can I convert Facebook time Text to Project Siena's Date value ?
    I want to show create_time on screen by my Localtime formatted text.
    Facebook time Text = 2014-07-14T11:22+0000
    I want to show = 2014/07/14 18:22
    My Time Zone is +09:00, Osaka/Japan.
    Currently I try it by Text/Replace/Replace/Replace/Left/DateValue/+ , etc.
    And I ask more simple way.
    Regards,
    Yoshihiro Kawabata

    Thank you Andy , and Robin, I can.
    Text(TimeValue(Substitute(ThisItem!created_time,"+0000",".000Z")),"yyyy/mm/dd hh:mm")
    At Facebook Albums's Gallary, I can convert from Facebook created_time to Localtime Text DateTime.
    and I hope more easy way like Excel Power Query's one.
    Regards,
    Yoshihiro Kawabata

Maybe you are looking for