Java.util.Data Exception when Testing Function

Hi All,
using VC I'm tring to test fuction HRPWC_RFC_AS_OVERVIEW. The field ViewId is the only one mandatory. When I've executed function I've obtained java.util.Date exception.
What does that mean? What should I set properly to test the function?
Regards,
Marek

Hi Marek,
I suppose you meant HRWPC_RFC_AS_OVERVIEW. This is an HR rfc that displays employee’s absence. I tested it in my VC and it works fine. I’ll need some more details on how you’ve created the model in order to help you. 
Regards,
Lisi

Similar Messages

  • Java.util.ConcurrentModification Exception

    Hi
    I am trying to write a caching object for my web application. I have a CacheMAnger thread which is started when Tomcat starts. I put objects onto the cache and give them a TTL. My thread occasionaly goes through and checks all the cached objects to see if they are expired. I thought this was a syncronization problem but I can't find where.
    It bombs when an object expires and gets removed form the cache. The error output is below as well as a copy of the CacheManager source.
    Thanks
    Michael
    <pre>
    2003-04-15 12:55:15,161 DEBUG cache.CacheManager$1 82 - CacheManager: CustomerList in Cache... expi
    ry?
    EXPIRY:Tue Apr 15 17:55:04 GMT 2003CURRENT:Tue Apr 15 17:55:15 GMT 2003
    2003-04-15 12:55:15,161 INFO cache.CacheManager$1 90 - CacheManager Removed CustomerList
    java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextEntry(HashMap.java:750)
    at java.util.HashMap$KeyIterator.next(HashMap.java:786)
    at net.talisen.tsr.cache.CacheManager$1.run(CacheManager.java:77)
    at java.lang.Thread.run(Thread.java:536)
    </pre>
    =====================================================================
    <pre>
    package net.talisen.tsr.cache;
    import java.util.HashMap;
    import java.util.Set;
    import java.util.Iterator;
    import org.apache.log4j.Logger;
    * Title: Caching
    * Description:
    * Copyright: Copyright (c) 2001
    * @author Michael Holly based on code from Jonathan Lurie in July 2001 Article in JavaWorld
    * @version 1.0
    public class CacheManager
    // This is the HashMap that contains all objects in the cache.
    private static java.util.HashMap cacheHashMap = new java.util.HashMap();
    // This object acts as a semaphore, which protects the HashMap
    // RESERVED FOR FUTURE USE private static Object lock = new Object();
    static
    try
    //Create background thread, which will be responsible for purging expired items.
    Thread threadCleanerUpper = new Thread( new Runnable()
    // The default time the thread should sleep between scans. The sleep
    // method takes in a millisecond value so 5000 = 5 Seconds.
    final static int milliSecondSleepTime = 20000;
    public void run()
    Logger log = Logger.getLogger(CacheManager.class);
    try
    // Sets up an infinite loop.
    while (true)
    log.debug( "CacheManager Scanning For Expired Objects...");
    // Get the set of all keys that are in cache. These are the unique
    // identifiers
    Set keySet = null;
    Iterator keys = null;
    Object key = null;
    Cacheable value = null;
    synchronized ( cacheHashMap )
    keySet = cacheHashMap.keySet();
    // An iterator is used to move through the Keyset //
    synchronized( keySet )
    keys = keySet.iterator();
    // Sets up a loop that will iterate through each key in the KeySet
    while(keys.hasNext())
    // Get the individual key. We need to hold on to this key
    // in case it needs to be removed
    synchronized ( keys )
    key = keys.next();
    // Get the cacheable object associated with the key inside the cache
    value = (Cacheable)cacheHashMap.get(key);
    log.debug( "CacheManager: " + value.getIdentifier() + " in Cache... expiry?");
    // Is the cacheable object expired?
    if (value.isExpired())
    //Yes it's expired! Remove it from the cache
    cacheHashMap.remove(key);
    cacheHashMap.notifyAll();
    log.info( "CacheManager Removed " + key.toString() );
    ***** A LRU (least-recently used) or
    LFU (least-frequently used) *****
    ******* would best be inserted here *****
    // Puts the thread to sleep. Don't need to check it continuously
    Thread.sleep( this.milliSecondSleepTime);
    catch (Exception e)
    e.printStackTrace();
    return;
    } // End run method
    }); // End class definition and close new thread definition
    // Sets the thread's priority to the minimum value.
    threadCleanerUpper.setPriority( Thread.MIN_PRIORITY );
    // Starts the thread.
    threadCleanerUpper.start();
    catch(Exception e)
    System.out.println( "CacheManager.Static Block: " + e);
    } // End static block
    // default constructor
    public CacheManager()
    * Used to add an object to the Cache
    * @param object the object to be added to the cache
    public static void putCache(Cacheable object)
    Logger log = Logger.getLogger(CacheManager.class);
    // Remember if the HashMap previously contains a mapping for the key, the old value
    // will be replaced. This is valid functioning.
    if ( object == null ) {
    log.debug("object to be cached is null. Caching was not attempted");
    return;
    if ( object.getIdentifier() == null ) {
    log.debug("object to be cached has a null key. Caching was not attempted");
    return;
    else
    synchronized ( cacheHashMap ) {
    cacheHashMap.put(object.getIdentifier(), object);
    log.debug( object.getIdentifier() + " cached");
    * Used to get an object from the cache
    * @param object the object to be retrieved from the cache
    * @return the cached object
    public static Cacheable getCache(Object identifier)
    Logger log = Logger.getLogger(CacheManager.class);
    if (identifier == null ) {
    log.debug( "Cache key was null" );
    return null;
    log.debug("Looking for " + identifier.toString() );
    //synchronized (lock) // UNCOMMENT LINE XXX
    //{                    // UNCOMMENT LINE XXX
    Cacheable object = null;
    synchronized ( cacheHashMap ) {
    object = ( Cacheable )cacheHashMap.get(identifier);
    // The code to create the object would be placed here.
    //} // UNCOMMENT LINE XXX
    if (object == null) {
    log.debug( "object not found in cache");
    return null;
    if (object.isExpired())
    log.debug( "object in cache was expired");
    synchronized ( cacheHashMap ) {
    cacheHashMap.remove(identifier);
    return null;
    else
    log.debug( object.getIdentifier() + " found");
    object.incrementCacheHits(); // track the performance
    return object;
    * Used to clear all objects from the cache
    public static void emptyCache()
    Logger log = Logger.getLogger(CacheManager.class);
    synchronized ( cacheHashMap ) {
    cacheHashMap.clear();
    log.debug( "Cache cleared");
    * Used to remove a particular object from the cache
    * @param identifier the object to be removed from the cache
    public static void removeEntry(Object identifier)
    Logger log = Logger.getLogger(CacheManager.class);
    if (identifier == null ) {
    log.debug( "Cache key was null" );
    return;
    synchronized ( cacheHashMap ) {
    cacheHashMap.remove(identifier);
    log.debug( identifier + " removed");
    * Used to get a count of cached objects
    * @return number of objects in the cache
    public static int getCount()
    synchronized ( cacheHashMap ) {
    return cacheHashMap.size();
    * Used to get a set of the entries in the cache
    * @param Set a set of the objects in the cache
    public static Set getEntrySet()
    synchronized ( cacheHashMap ) {
    return cacheHashMap.entrySet();
    * Used to get a html page on the status of the cache
    public static String getStatus()
    Set keySet = null;
    Iterator keys = null;
    synchronized (cacheHashMap) {
    keySet = cacheHashMap.keySet();
    keys = keySet.iterator();
    String status = new String();
    status += ( "<html><head>");
    status += ( "<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />");
    status += ( "<meta http-equiv=\"Pragma\" content=\"no-cache\" />");
    status += ( "<meta http-equiv=\"Expires\" content=\"0\" /> ");
    status += ( "<meta http-equiv=\"refresh\" content=\"10\" /> ");
    status += ( "</head><body>" );
    status += ( "<p><h4>Cache Status " + (new java.util.Date()).toString() + "</h4>" );
    status += ( "<br>Page automagically refreshed every 10 seconds<br>" );
    status += ( getCount() + " object(s) cached" );
    status += ( "<p>Cache contains: " );
    while(keys.hasNext())
    Object key = keys.next();
    // Get the cacheable object associated with the key inside the cache
    Cacheable object = null;
    synchronized ( cacheHashMap ) {
    object = (Cacheable)cacheHashMap.get(key);
    status += ( "<br><b>ID:</b><i>" + object.getIdentifier() + "</i>" );
    status += ( "<br>   <b>Class of:</b><i>" + object.toString() + "</i>");
    status += ( "<br>   <b> Expires at:</b><i>" + object.getExpireDate() + "</i>");
    status += ( "<br>   <b> Cache Hits:</b><i>" + object.getCacheHits().toString() + "</i>");
    status += ( "<br>   <b> Object Size:</b><i>" + object.getByteCount(object).toString() + "</i>");
    int bytesServed = object.getCacheHits().intValue() * object.getByteCount(object).intValue();
    double eff = 0.0;
    // handle divide by 0
    if ( bytesServed > 0 ) {
    eff = ( bytesServed - object.getByteCount(object).intValue() ) / bytesServed;
    status += ( "<br>   <b> Cache Efficiency:</b><i>" + eff + "</i><br><br>");
    status += ( "</body></html>" );
    return status;
    * Used to get a html page on the status of the cache
    public static String flushCache()
    Set keySet = null;
    Iterator keys = null;
    synchronized ( cacheHashMap ) {
    keySet = cacheHashMap.keySet();
    keys = keySet.iterator();
    String status = new String();
    status += ( "<html><head>");
    status += ( "<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />");
    status += ( "<meta http-equiv=\"Pragma\" content=\"no-cache\" />");
    status += ( "<meta http-equiv=\"Expires\" content=\"0\" /> ");
    status += ( "</head><body>" );
    status += ( "<p><h4>Cache status before cache reset " + (new java.util.Date()).toString() + "</h4>" );
    status += ( "<p>Cache size: " + getCount() + " object(s) cached" );
    status += ( "<p>Cache contains: " );
    while(keys.hasNext())
    Object key = keys.next();
    // Get the cacheable object associated with the key inside the cache
    Cacheable object = null;
    synchronized ( cacheHashMap ) {
    object = (Cacheable)cacheHashMap.get(key);
    status += ( "<br><b>ID:</b><i>" + object.getIdentifier() + "</i> <b>Class of:</b><i>" + object.toString() );
    status += ( "</i><b> Expires at:</b>" + object.getExpireDate() + "</i>");
    CacheManager.emptyCache();
    status += ( "<p><h4>Cache status after cache reset " + (new java.util.Date()).toString() + "</h4>" );
    status += ( "<p>Cache size: " + CacheManager.getCount() + " object(s) cached" );
    status += ( "<p>Cache contains: " );
    Set newKeySet = null;
    Iterator newKeys = null;
    synchronized ( cacheHashMap ) {
    newKeySet = cacheHashMap.keySet();
    newKeys = newKeySet.iterator();
    // this really never gets executed
    while(newKeys.hasNext())
    Object key = newKeys.next();
    // Get the cacheable object associated with the key inside the cache
    Cacheable object = null;
    synchronized ( cacheHashMap ) {
    object = (Cacheable)cacheHashMap.get(key);
    status += ( "<br><b>ID:</b><i>" + object.getIdentifier() + "</i> <b>Class of:</b><i>" + object.toString() );
    status += ( "</i><b> Expires at:</b>" + object.getExpireDate() + "</i>");
    status += ( "</body></html>" );
    return status;
    </pre>

    I think my problem is that I am iterating through all the values of the hashMap and when I find one and delete it then the iterator becomes invalid? Checkout the while loop in the thread.
    I'm not sure that this scenario is consistant with the error I'm getting.
    I had tried something similar to what you described... maybe I missed something. Let me try it again...
    I have reposted my code below with the proper tags to render the code if you need to reference for any more suggestions.
    Michael
    package net.talisen.tsr.cache;
    import java.util.HashMap;
    import java.util.Set;
    import java.util.Iterator;
    import org.apache.log4j.Logger;
    * Title:        Caching
    * Description:
    * Copyright:    Copyright (c) 2001
    * @author Michael Holly based on code from Jonathan Lurie in July 2001 Article in JavaWorld
    * @version 1.0
    public class CacheManager
       // This is the HashMap that contains all objects in the cache.
       private static java.util.HashMap cacheHashMap = new java.util.HashMap();
       // This object acts as a semaphore, which protects the HashMap
       // RESERVED FOR FUTURE USE  private static Object lock = new Object();
       static
          try
             //Create background thread, which will be responsible for purging expired items.
             Thread threadCleanerUpper = new Thread( new Runnable()
                //  The default time the thread should sleep between scans.  The sleep
                //  method takes in a millisecond value so 5000 = 5 Seconds.
                final static int milliSecondSleepTime = 20000;
                public void run()
                   Logger log = Logger.getLogger(CacheManager.class);
                   try
                      // Sets up an infinite loop.
                      while (true)
                         log.debug( "CacheManager Scanning For Expired Objects...");
                         // Get the set of all keys that are in cache.  These are the unique
                         // identifiers
                         Set keySet      = null;
                         Iterator keys   = null;
                         Object key      = null;
                         Cacheable value = null;
                         synchronized ( cacheHashMap )
                            keySet = cacheHashMap.keySet();
                            // An iterator is used to move through the Keyset //
                            synchronized( keySet )
                               keys = keySet.iterator();
                            // Sets up a loop that will iterate through each key in the KeySet
                            while(keys.hasNext())
                               // Get the individual key. We need to hold on to this key
                               // in case it needs to be removed
                               synchronized ( keys )
                                  key = keys.next();
                               // Get the cacheable object associated with the key inside the cache
                               value = (Cacheable)cacheHashMap.get(key);
                               log.debug( "CacheManager: " + value.getIdentifier() + " in Cache... expiry?");
                               // Is the cacheable object expired?
                               if (value.isExpired())
                                  //Yes it's expired! Remove it from the cache
                                  cacheHashMap.remove(key);
                                  cacheHashMap.notifyAll();
                                  log.info( "CacheManager Removed " + key.toString() );
                             ***** A LRU (least-recently used) or
                                                  LFU (least-frequently used) *****
                             ******* would best be inserted here              *****
                         // Puts the thread to sleep. Don't need to check it continuously
                         Thread.sleep( this.milliSecondSleepTime);
                   catch (Exception e)
                      e.printStackTrace();
                   return;
                } // End run method
             }); // End class definition and close new thread definition
             // Sets the thread's priority to the minimum value.
             threadCleanerUpper.setPriority( Thread.MIN_PRIORITY );
             // Starts the thread.
             threadCleanerUpper.start();
          catch(Exception e)
             System.out.println( "CacheManager.Static Block: " + e);
       } // End static block
       // default constructor
       public CacheManager()
       * Used to add an object to the Cache
       * @param object the object to be added to the cache
       public static void putCache(Cacheable object)
          Logger log = Logger.getLogger(CacheManager.class);
          // Remember if the HashMap previously contains a mapping for the key, the old value
          // will be replaced.  This is valid functioning.
          if ( object == null ) {
             log.debug("object to be cached is null. Caching was not attempted");
             return;
          if ( object.getIdentifier() == null ) {
             log.debug("object to be cached has a null key. Caching was not attempted");
             return;
          else
             synchronized ( cacheHashMap ) {
                cacheHashMap.put(object.getIdentifier(), object);
                log.debug( object.getIdentifier() + " cached");
       * Used to get an object from the cache
       * @param object the object to be retrieved from the cache
       * @return the cached object
       public static Cacheable getCache(Object identifier)
          Logger log = Logger.getLogger(CacheManager.class);
          if (identifier == null ) {
             log.debug( "Cache key was null" );
             return null;
          log.debug("Looking for " + identifier.toString() );
          Cacheable object = null;
          synchronized ( cacheHashMap )  {
             object = ( Cacheable )cacheHashMap.get(identifier);
          if (object == null) {
             log.debug( "object not found in cache");
             return null;
          if (object.isExpired())
             log.debug( "object in cache was expired");
             synchronized ( cacheHashMap )  {
                cacheHashMap.remove(identifier);
             return null;
          else
             log.debug( object.getIdentifier() + " found");
             object.incrementCacheHits(); // track the performance
             return object;
       * Used to clear all objects from the cache
       public static void emptyCache()
          Logger log = Logger.getLogger(CacheManager.class);
          synchronized ( cacheHashMap )  {
             cacheHashMap.clear();
          log.debug( "Cache cleared");
       * Used to remove a particular object from the cache
       * @param identifier the object to be removed from the cache
       public static void removeEntry(Object identifier)
          Logger log = Logger.getLogger(CacheManager.class);
          if (identifier == null ) {
             log.debug( "Cache key was null" );
             return;
          synchronized ( cacheHashMap )  {
             cacheHashMap.remove(identifier);
          log.debug( identifier + " removed");
       * Used to get a count of cached objects
       * @return number of objects in the cache
       public static int getCount()
          synchronized ( cacheHashMap )  {
             return cacheHashMap.size();
       * Used to get a set of the entries in the cache
       * @param Set a set of the objects in the cache
       public static Set getEntrySet()
          synchronized ( cacheHashMap )  {
             return cacheHashMap.entrySet();
       * Used to get a html page on the status of the cache
       public static String getStatus()
          Set keySet = null;
          Iterator keys = null;
          synchronized (cacheHashMap) {
             keySet = cacheHashMap.keySet();
             keys = keySet.iterator();
          String status = new String();
          status += ( "<html><head>");
          status += ( "<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />");
          status += ( "<meta http-equiv=\"Pragma\" content=\"no-cache\" />");
          status += ( "<meta http-equiv=\"Expires\" content=\"0\" /> ");
          status += ( "<meta http-equiv=\"refresh\" content=\"10\" /> ");
          status += ( "</head><body>" );
          status += ( "<p><h4>Cache Status " + (new java.util.Date()).toString() + "</h4>" );
          status += ( "<br>Page automagically refreshed every 10 seconds<br>" );
          status += ( getCount() + " object(s) cached" );
          status += ( "<p>Cache contains: " );
          while(keys.hasNext())
             Object key = keys.next();
             // Get the cacheable object associated with the key inside the cache
             Cacheable object = null;
             synchronized ( cacheHashMap )  {
                object = (Cacheable)cacheHashMap.get(key);
             status += ( "<br><b>ID:</b><i>" + object.getIdentifier() + "</i>"  );
             status += ( "<br>���<b>Class�of:</b><i>" + object.toString() + "</i>");
             status += ( "<br>���<b> Expires at:</b><i>" + object.getExpireDate() + "</i>");
             status += ( "<br>���<b> Cache Hits:</b><i>" + object.getCacheHits().toString() + "</i>");
             status += ( "<br>���<b> Object Size:</b><i>" + object.getByteCount(object).toString() + "</i>");
             int bytesServed = object.getCacheHits().intValue() * object.getByteCount(object).intValue();
             double eff = 0.0;
             // handle divide by 0
             if ( bytesServed > 0 ) {
                eff = ( bytesServed - object.getByteCount(object).intValue() ) / bytesServed;
             status += ( "<br>���<b> Cache Efficiency:</b><i>" + eff + "</i><br><br>");
          status += ( "</body></html>" );
          return status;
       * Used to get a html page on the status of the cache
       public static String flushCache()
          Set keySet = null;
          Iterator keys = null;
          synchronized ( cacheHashMap )  {
             keySet = cacheHashMap.keySet();
             keys   = keySet.iterator();
          String status = new String();
          status += ( "<html><head>");
          status += ( "<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />");
          status += ( "<meta http-equiv=\"Pragma\" content=\"no-cache\" />");
          status += ( "<meta http-equiv=\"Expires\" content=\"0\" /> ");
          status += ( "</head><body>" );
          status += ( "<p><h4>Cache status before cache reset " + (new java.util.Date()).toString() + "</h4>" );
          status += ( "<p>Cache size: " + getCount() + " object(s) cached" );
          status += ( "<p>Cache contains: " );
          while(keys.hasNext())
             Object key = keys.next();
             // Get the cacheable object associated with the key inside the cache
             Cacheable object = null;
             synchronized ( cacheHashMap )  {
                object = (Cacheable)cacheHashMap.get(key);
             status += ( "<br><b>ID:</b><i>" + object.getIdentifier() + "</i>  <b>Class of:</b><i>" + object.toString() );
             status += ( "</i><b> Expires at:</b>" + object.getExpireDate() + "</i>");
          CacheManager.emptyCache();
          status += ( "<p><h4>Cache status after cache reset " + (new java.util.Date()).toString() + "</h4>" );
          status += ( "<p>Cache size: " + CacheManager.getCount() + " object(s) cached" );
          status += ( "<p>Cache contains: " );
          Set newKeySet = null;
          Iterator newKeys = null;
          synchronized ( cacheHashMap )  {
             newKeySet = cacheHashMap.keySet();
             newKeys   = newKeySet.iterator();
          // this really never gets executed
          while(newKeys.hasNext())
             Object key = newKeys.next();
             // Get the cacheable object associated with the key inside the cache
             Cacheable object = null;
             synchronized ( cacheHashMap )  {
                object = (Cacheable)cacheHashMap.get(key);
             status += ( "<br><b>ID:</b><i>" + object.getIdentifier() + "</i>  <b>Class of:</b><i>" + object.toString() );
             status += ( "</i><b> Expires at:</b>" + object.getExpireDate() + "</i>");
          status += ( "</body></html>" );
          return status;

  • Java.util.Date badly serialized to java.sql.Timestamp Coherence 3.5.2

    Hi all,
    I'm running into this odd behaviour.
    I serialize java.util.Date objects to cache and when I read them back from cache, they appear to be java.sql.Timestamp types.
    I've isolated a junit test for that.
    Do you know why Coherence changes the type in the middle?
    Regards
    Harry.
    import java.util.Date;
    import org.junit.Assert;
    import org.junit.Test;
    import com.tangosol.io.Serializer;
    import com.tangosol.io.pof.ConfigurablePofContext;
    import com.tangosol.util.ExternalizableHelper;
    public class DatePofSerialTest {
         @Test
         public void testCobdate() throws Exception {
              Date date=new Date();
              Serializer serial = new ConfigurablePofContext();//"coherence-pof-config.xml");
              Date date2=(Date)ExternalizableHelper.fromBinary(ExternalizableHelper.toBinary(date, serial), serial);
              System.out.println(serial +" -- Date to serailize ["+ date.getClass() + "]");
              System.out.println(serial +" -- Date from deserialize ["+ date2.getClass() + "]");
              Assert.assertEquals(date, date2);/* Of course this passes, as both refer to the same time (long)*/
    {code}
    This gives as output
    {code:title=output |borderStyle=solid}
    log4j:WARN No appenders could be found for logger (Coherence).
    log4j:WARN Please initialize the log4j system properly.
    com.tangosol.io.pof.ConfigurablePofContext {location=coherence-pof-config.xml} -- Date to serailize [class java.util.Date]
    com.tangosol.io.pof.ConfigurablePofContext {location=coherence-pof-config.xml} -- Date from deserialize [class java.sql.Timestamp]
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Harry,
    It looks like the same issue as ...
    PofExtractor with java.util.Date results in ClassCastException
    It was fixed in version 3.5.4.
    Thanks

  • Error while deploying a web service whose return type is java.util.Date

    Hi
    I have written a simple web service which takes in a date input (java.util.Date) and returns the same date back to the client.
    public interface Ping extends Remote
    * A simple method that pings the server to test the webservice.
    * It sends a datetime to the server which returns the datetime.
    * @param pingDateRequest A datetime sent to the server
    * @returns The original datetime
    public Date ping(Date pingDateRequest) throws RemoteException;
    The generation of the Web service related files goes smoothly in JDeveloper 10g. The problem arises when I try to deploy this web service on the Oracle 10g (10.0.3) OC4J standalone. it gives me the following error on the OC4J console :
    E:\Oracle\oc4j1003\j2ee\home\application-deployments\Sachin-TradingEngineWS-WS\
    WebServices\com\sachin\tradeengine\ws\Ping_Tie.java:57: ping(java.util.Date) in com.sachin.tradeengine.ws.Ping cannot be applied to (java.util.Calendar) _result  = ((com.sachin.tradeengine.ws.Ping) getTarget()).ping
    (myPing_Type.getDate_1());
    ^
    1 error
    04/03/23 17:17:35 Notification ==&gt; Application Deployer for Sachin-TradingEngineWS-WS FAILED: java.lang.InstantiationException: Error compiling :E:\Oracle\oc4j1003\j2ee\home\applications\Sachin-TradingEngineWS-WS\WebServices: Syntax error in source [ 2004-03-23T17:17:35.937GMT+05:30 ]
    I read somewhere that the conversion between java to xml datatype and vice versa fails for java.util.Date, so it is better to use java.util.Calendar. When I change the code to return a java.util.Calendar then the JDeveloper prompts me the following failure:
    Method Ping: the following parameter types do not have an XML Schema mapping and/or serializer specified : java.util.Calendar.
    This forces me to return a String data.
    I would appreciate if someone can help me out.
    Thanks
    Sachin Mathias
    Datamatics Ltd.

    Hi
    I got the web service working with some work around. But I am not sure it this approach would be right and good.
    I started altogether afresh. I did the following step :
    1. Created an Interface (Ping.java) for use in web Service as follows :
    public interface Ping extends Remote{
    public java.util.Date ping(java.util.Date pingDateRequest)
    throws RemoteException;
    2. Implemented the above interface in PingImpl.java as follows :
    public class PingImpl implements Ping
    public java.util.Date ping(java.util.Date pingDateRequest) throws RemoteException {
    System.out.println("PingImpl: ping() return datetime = " + pingDateRequest.toString());
    return pingDateRequest;
    3. Compiled the above 2 java files.
    4. Generated a Stateless Java Web Service with the help of JDeveloper. This time the generation was sucessful.(If I had "java.util.Calendar" in place of "java.util.Date" in the java code of the above mentioned files the web service generation would prompt me for error)
    5. After the generation of Web Service, I made modification to the Ping interface and its implementing class. In both the files I replaced "java.util.Date" with "java.util.Calendar". The modified java will look as follows :
    Ping.Java
    =========
    public interface Ping extends Remote{
    public java.util.Calendar ping(java.util.Calendar pingDateRequest)
    throws RemoteException;
    PingImpl.Java
    ================
    public class PingImpl implements Ping
    public java.util.Calendar ping(java.util.Calendar pingDateRequest) throws RemoteException {
    System.out.println("PingImpl: ping() return datetime = " + pingDateRequest.toString());
    return pingDateRequest;
    6. Now I recompile both the java files.
    7. Withour regenerating the Web Service I deploy the Web Service on OC4j 10.0.3 from JDeveloper. This time the deployment was sucessful.(The Deployment fails if I don't follow the step 5.)
    8. Now I generated a Stub from JDeveloper and accessed the stub from a client. It works fine. Here if you see the Stub code it takes java.util.Date as a parameter and returns a java.util.Date. (Mind you I am accepting a java.util.Calendar and returning the same in my Web Service interface. Step 5)
    The confusing thing is the Serialization and Deserialization of Data from Client java data to Soap message and Soap message to Server java data.
    From Client to SOAP :
    java.util.Date to datetime
    From SOAP to Server :
    datetime to java.util.Calendar
    From Server to SOAP :
    java.util.Calendar to datetime
    From SOAP to Client :
    datetime to java.util.Date (I am not able to understand this part of the conversion)
    Any help or inputs would be appreciated.
    Thanks
    Sachin Mathias

  • Java.util.Date

    I have a session bean which is published as a web service. The methods in this bean have a return type of java.util.Date.
    I am unable to invoke any of these web services method in Studio creator. These work fine with a .NET client. The exception is as follows:
    InvocationTargetException com.sun.rave.websvc.ui.ReflectionHelper.callMethodWithParams(ReflectionHelper.java:451) com.sun.rave.websvc.ui.TestWebServiceMethodDlg.invokeMethod(TestWebServiceMethodDlg.java:361) com.sun.rave.websvc.ui.TestWebServiceMethodDlg.access$500(TestWebServiceMethodDlg.java:55) com.sun.rave.websvc.ui.TestWebServiceMethodDlg$4.run(TestWebServiceMethodDlg.java:301) java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) java.awt.EventQueue.dispatchEvent(EventQueue.java:454) java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) java.awt.EventDispatchThread.run(EventDispatchThread.java:100) null sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:324) com.sun.rave.websvc.ui.ReflectionHelper.callMethodWithParams(ReflectionHelper.java:445) com.sun.rave.websvc.ui.TestWebServiceMethodDlg.invokeMethod(TestWebServiceMethodDlg.java:361) com.sun.rave.websvc.ui.TestWebServiceMethodDlg.access$500(TestWebServiceMethodDlg.java:55) com.sun.rave.websvc.ui.TestWebServiceMethodDlg$4.run(TestWebServiceMethodDlg.java:301) java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) java.awt.EventQueue.dispatchEvent(EventQueue.java:454) java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) java.awt.EventDispatchThread.run(EventDispatchThread.java:100) Runtime exception; nested exception is: deserialization error: java.lang.NumberFormatException: For input string: "" com.sun.xml.rpc.client.StreamingSender._handleRuntimeExceptionInSend(StreamingSender.java:248) com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:230) webservice.AddDates_Stub.addToDay(AddDates_Stub.java:68) webservice.AddDatesServiceClient.adddatesserviceAddToDay(AddDatesServiceClient.java:19) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:324) com.sun.rave.websvc.ui.ReflectionHelper.callMethodWithParams(ReflectionHelper.java:445) com.sun.rave.websvc.ui.TestWebServiceMethodDlg.invokeMethod(TestWebServiceMethodDlg.java:361) com.sun.rave.websvc.ui.TestWebServiceMethodDlg.access$500(TestWebServiceMethodDlg.java:55) com.sun.rave.websvc.ui.TestWebServiceMethodDlg$4.run(TestWebServiceMethodDlg.java:301) java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) java.awt.EventQueue.dispatchEvent(EventQueue.java:454) java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) java.awt.EventDispatchThread.run(EventDispatchThread.java:100) deserialization error: java.lang.NumberFormatException: For input string: "" com.sun.xml.rpc.encoding.SimpleTypeSerializer.deserialize(SimpleTypeSerializer.java:142) webservice.Date_SOAPSerializer.doDeserialize(Date_SOAPSerializer.java:60) com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSerializerBase.java:167) com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(ReferenceableSerializerImpl.java:134) webservice.AddDates_AddToDay_ResponseStruct2_SOAPSerializer.doDeserialize(AddDates_AddToDay_ResponseStruct2_SOAPSerializer.java:40) com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSerializerBase.java:167) com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(ReferenceableSerializerImpl.java:134) webservice.AddDates_Stub._deserialize_AddToDay(AddDates_Stub.java:489) webservice.AddDates_Stub._readFirstBodyElement(AddDates_Stub.java:458) com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:158) webservice.AddDates_Stub.addToDay(AddDates_Stub.java:68) webservice.AddDatesServiceClient.adddatesserviceAddToDay(AddDatesServiceClient.java:19) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:324) com.sun.rave.websvc.ui.ReflectionHelper.callMethodWithParams(ReflectionHelper.java:445) com.sun.rave.websvc.ui.TestWebServiceMethodDlg.invokeMethod(TestWebServiceMethodDlg.java:361) com.sun.rave.websvc.ui.TestWebServiceMethodDlg.access$500(TestWebServiceMethodDlg.java:55) com.sun.rave.websvc.ui.TestWebServiceMethodDlg$4.run(TestWebServiceMethodDlg.java:301) java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) java.awt.EventQueue.dispatchEvent(EventQueue.java:454) java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

    Hi Meera
    This works fine in creator. I tested with a webservice having a method which returns java.util.date. I used the same code in that method to return java.util.Date. But the same method was returning a Calendar object instead of Date. So I added getTime() method to get the Date.
    Can you post few lines of your code that you are writing in Creator.
    Thanks
    Creator Support

  • What's wrong with java.util.Date type?

    Hi!
    When I try to persist object having field of type java.util.Date I get the
    following SQL logged by Kodo with subsequent transaction rollback:
    2002-11-14 15:03:35,099 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnecti
    onFactoryImpl.supportcrm/kodo] INSERT INTO BILLY.TT_COMMENTS(COMMENT_TYPE,
    TEXT,
    CREATED_BY, ID, SUBJECT, CREATE_DATE, TT_MAIN_ID) VALUES (1, '1', 10, 279,
    '1',
    {ts '2002-11-14 15:03:35.059'}, 147)
    When I change "{ts '2002-11-14 15:03:35.059'}" with "TO_DATE('2002-11-14
    15:03', 'YYYY-DD-MM HH24:MI')" in SQL editor
    and execute it everything works fine.
    What does "{ts '..'}" mean? Is it a SQL generation error?
    Thank you in advance.
    Best regards,
    Alexey Maslov

    I've created my own dictionary with dateToSQL() method overridden.
    Now it works fine. But it's a kind of strange. Oracle is used often and my
    JDBC drivers
    are the most recent (at least, from the oracle.com).
    Anyway, thank you again.
    "Alexey Maslov" <[email protected]> wrote in message
    news:[email protected]...
    Patric,
    Thank you for response.
    We're using Oracle 8.1.7 via OCI driver from Oracle 9.2.
    I've already tried 2.4.0 and it works fine there but I've found another
    problem there
    preventing me from using it. See my post in solarmetric.kodo.betanewsgroup.
    >
    "Patrick Linskey" <[email protected]> wrote in message
    news:[email protected]...
    That's odd -- what version of Oracle are you using?
    Moving to Kodo JDO 2.4.0
    (http://www.solarmetric.com/Software/beta/2.4.0) will almost certainly
    get rid of this problem, as we use exclusively prepared statements in
    it, and therefore pass dates etc. to JDBC as parameters.
    But, to get things working with your Oracle database and Kodo JDO 2.3,
    you could create your own extension of OracleDictionary and override the
    dateToSQL() method to generate the appropriate TO_DATE() syntax. See our
    documentation for more details on creating custom database dictionaries.
    -Patrick
    Alexey Maslov wrote:
    I've added TRACE level logging for transactions in JBoss and got
    original
    exception:
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=INSERT
    INTO
    BILLY.T
    T_MAIN(TT_SOLUTION_ID, DELAY_REASON, TT_STATE_ID, ID, CONTACT_PHONE,
    CANCEL_REAS
    ON, OPER_DESCR, TT_TYPE_ID, CREATED_BY, EXP_CLOSE_DATE,SERV_OPEN_DATE,
    OPEN_DAT
    E, FLAGS, TAKEN_BY, TT_CAT_ID, SUBJECT_ID, SUBJECT, SERV_CLOSE_DATE)
    VALUES
    (NUL
    L, NULL, 1, 439, NULL, NULL, '____________ ________________ ________________', 7, 5, {ts
    '2002-11-14 1
    8:38:16.075'}, NULL, {ts '2002-11-14 18:18:16.075'}, 0, NULL, 11,24099,
    '1', NU
    LL)] ORA-00904: invalid column name
    at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwFatal(SQLEx
    ceptions.java:17)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.insert(JDBCSt
    oreManager.java:421)
    at
    com.solarmetric.kodo.runtime.datacache.DataCacheStoreManager.insert(D
    ataCacheStoreManager.java:265)
    at
    com.solarmetric.kodo.runtime.StateManagerImpl.insert(StateManagerImpl
    ..java:1783)
    atcom.solarmetric.kodo.runtime.PNewState.flush(PNewState.java:31)
    at
    com.solarmetric.kodo.runtime.StateManagerImpl.flush(StateManagerImpl.
    java:372)
    at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(Persistence
    ManagerImpl.java:426)
    at
    com.solarmetric.kodo.ee.EEPersistenceManager.beforeCompletion(EEPersi
    But when I try to execute the statement above against the database
    manually
    everything works fine.
    I'm absolutely desperate!
    P.S. On 2.4.0 RC the operation invoking this database insert completes
    fine.
    "Alexey Maslov" wrote in message
    news:[email protected]...
    Hi!
    When I try to persist object having field of type java.util.Date I
    get
    the
    following SQL logged by Kodo with subsequent transaction rollback:
    2002-11-14 15:03:35,099 INFO
    [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnecti
    onFactoryImpl.supportcrm/kodo] INSERT INTOBILLY.TT_COMMENTS(COMMENT_TYPE,
    TEXT,
    CREATED_BY, ID, SUBJECT, CREATE_DATE, TT_MAIN_ID) VALUES (1, '1',
    10,
    >>>
    279,
    '1',
    {ts '2002-11-14 15:03:35.059'}, 147)
    When I change "{ts '2002-11-14 15:03:35.059'}" with
    "TO_DATE('2002-11-14
    15:03', 'YYYY-DD-MM HH24:MI')" in SQL editor
    and execute it everything works fine.
    What does "{ts '..'}" mean? Is it a SQL generation error?
    Thank you in advance.
    Best regards,
    Alexey Maslov
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com
    Best regards,
    Alexey Maslov

  • A bug in java.util.Date module?

    When I try to execute this code:
    private java.util.Date getStringAsDate(String s) throws Exception {
         SimpleDateFormat fmt = new SimpleDateFormat("DD.MM.yyyy");
             return fmt.parse(s);
    java.util.Date one = getStringAsDate("8.6.2005"), two = getStringAsDate("8.7.2005");
    if (one.compareTo (two) ==0 )
       System.out.println("Equals!");
    else
       System.out.println("Not equals!");
    System.out.println(one);
    System.out.println(two);I get this result:
    Equals!
    Sat Jan 08 00:00:00 GMT+01:00 2005
    Sat Jan 08 00:00:00 GMT+01:00 2005
    My locales are Czech, time zone GMT+01. Thoughts?

    Thanks.
    I was looking for an error in months as they were
    incorrect...Look into the API and you should see why the month value is wrong for the pattern you wrote:
    http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.htmlThe hint is in the definition of 'D' versus 'd'.

  • How to insert java.util.Date to Oracle by OraclePrepaidStatement

    Hi all,
    I am trying to insert the date data to oracle a lot. But all of them works wrong???
    Here's a code:
    package main;
    import oracle.jdbc.driver.*;
    import oracledb.OraCon;
    import java.text.SimpleDateFormat;
    public class inmain {
          * @param args
         public static void main(String[] args)
              OraCon conn = new OraCon();
              conn.alloc();
              String sql = "insert into test(c_Date, c_Float, c_Int, c_String) values (?,?,?,?)";
              java.text.SimpleDateFormat MMddyyyyHHmmss = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
              try
                   OraclePreparedStatement ps = (OraclePreparedStatement)conn.oraconnection.prepareStatement(sql);
                   String date = "12/12/2006 17:33:01";
                   java.util.Date ud = MMddyyyyHHmmss.parse(date);
                   java.sql.Date dd = new java.sql.Date(ud.getTime());
                   float ff = Integer.parseInt("1");
                   ps.setDate(1, dd);
                   ps.setFloat(2, ff);
                   ps.setInt(3, 4);
                   ps.setString(4, "This is test");
                   ps.executeUpdate();
              catch(Exception e)
                   e.printStackTrace();
    }Then I select from the table.
    select to_char(test.C_DATE, 'yyyy-MM-dd HH24:mi:ss')
    from test
    Its result is:
    2006-12-12 00:00:00
    I wanna to show 2006-12-12 17:33:01.
    How?

    Dear NiallMcG,
    Thank you very much, It now works fine.
    package main;
    import oracle.jdbc.driver.*;
    import oracledb.OraCon;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    public class inmain {
          * @param args
         public static void main(String[] args)
              OraCon conn = new OraCon();
              conn.alloc();
              String sql = "insert into test(c_Date, c_Float, c_Int, c_String) values (?,?,?,?)";
              java.text.SimpleDateFormat MMddyyyyHHmmss = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
              try
                   OraclePreparedStatement ps = (OraclePreparedStatement)conn.oraconnection.prepareStatement(sql);
                   String date = "12/12/2006 17:33:01";
                   java.util.Date ud = MMddyyyyHHmmss.parse(date);
                   float ff = Integer.parseInt("1");
                   Timestamp ts = new java.sql.Timestamp(ud.getTime());
                   ps.setTimestamp(1,ts);
                   ps.setFloat(2, ff);
                   ps.setInt(3, 4);
                   ps.setString(4, "This is test");
                   ps.executeUpdate();                    
              catch(Exception e)
                   e.printStackTrace();
              conn.release();
    }

  • Java.sql.Date vs java.util.Date vs. java.util.Calendar

    All I want to do is create a java.sql.Date subclass which has the Date(String) constructor, some checks for values and a few other additional methods and that avoids deprecation warnings/errors.
    I am trying to write a wrapper for the java.sql.Date class that would allow a user to create a Date object using the methods:
    Date date1 = new Date(2003, 10, 7);ORDate date2 = new Date("2003-10-07");I am creating classes that mimic MySQL (and eventually other databases) column types in order to allow for data checking since MySQL does not force checks or throw errors as, say, Oracle can be set up to do. All the types EXCEPT the Date, Datetime, Timestamp and Time types for MySQL map nicely to and from java.sql.* objects through wrappers of one sort or another.
    Unfortunately, java.sql.Date, java.sql.Timestamp, java.sql.Time are not so friendly and very confusing.
    One of my problems is that new java.sql.Date(int,int,int); and new java.util.Date(int,int,int); are both deprecated, so if I use them, I get deprecation warnings (errors) on compile.
    Example:
    public class Date extends java.sql.Date implements RangedColumn {
      public static final String RANGE = "FROM '1000-01-01' to '8099-12-31'";
      public static final String TYPE = "DATE";
       * Minimum date allowed by <strong>MySQL</strong>. NOTE: This is a MySQL
       * limitation. Java allows dates from '0000-01-01' while MySQL only supports
       * dates from '1000-01-01'.
      public static final Date MIN_DATE = new Date(1000 + 1900,1,1);
       * Maximum date allowed by <strong>Java</strong>. NOTE: This is a Java limitation, not a MySQL
       * limitation. MySQL allows dates up to '9999-12-31' while Java only supports
       * dates to '8099-12-31'.
      public static final Date MAX_DATE = new Date(8099 + 1900,12,31);
      protected int _precision = 0;
      private java.sql.Date _date = null;
      public Date(int year, int month, int date) {
        // Deprecated, so I get deprecation warnings from the next line:
        super(year,month,date);
        if(! isWithinRange(this))
          throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
      public Date(String s) {
        super(0l);
        // Start Cut-and-paste from java.sql.Date.valueOf(String s)
        int year;
        int month;
        int day;
        int firstDash;
        int secondDash;
        if (s == null) throw new java.lang.IllegalArgumentException();
        firstDash = s.indexOf('-');
        secondDash = s.indexOf('-', firstDash+1);
        if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length()-1)) {
          year = Integer.parseInt(s.substring(0, firstDash)) - 1900;
          month = Integer.parseInt(s.substring(firstDash+1, secondDash)) - 1;
          day = Integer.parseInt(s.substring(secondDash+1));
        } else {
          throw new java.lang.IllegalArgumentException();
        // End Cut-and-paste from java.sql.Date.valueOf(String s)
        // Next three lines are deprecated, causing warnings.
        this.setYear(year);
        this.setMonth(month);
        this.setDate(day);
        if(! isWithinRange(this))
          throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
      public static boolean isWithinRange(Date date) {
        if(date.before(MIN_DATE))
          return false;
        if(date.after(MAX_DATE))
          return false;
        return true;
      public String getRange() { return RANGE; }
      public int getPrecision() { return _precision; }
      public String getType() { return TYPE; }
    }This works well, but it's deprecated. I don't see how I can use a java.util.Calendar object in stead without either essentially re-writing java.sql.Date almost entirely or losing the ability to be able to use java.sql.PreparedStatement.get[set]Date(int pos, java.sql.Date date);
    So at this point, I am at a loss.
    The deprecation documentation for constructor new Date(int,int,int)says "instead use the constructor Date(long date)", which I can't do unless I do a bunch of expensive String -> [Calendar/Date] -> Milliseconds conversions, and then I can't use "super()", so I'm back to re-writing the class again.
    I can't use setters like java.sql.Date.setYear(int) or java.util.setMonth(int) because they are deprecated too: "replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date)". Well GREAT, I can't go from a Date object to a Calendar object, so how am I supposed to use the "Calendar.set(...)" method!?!? From where I'm sitting, this whole Date deprecation thing seems like a step backward not forward, especially in the java.sql.* realm.
    To prove my point, the non-deprecated method java.sql.Date.valueOf(String) USES the DEPRECATED constructor java.util.Date(int,int,int).
    So, how do I create a java.sql.Date subclass which has the Date(String) constructor that avoids deprecation warnings/errors?
    That's all I really want.
    HELP!

    I appreciate your help, but what I was hoping to accomplish was to have two constructors for my java.sql.Date subclass, one that took (int,int,int) and one that took ("yyyy-MM-dd"). From what I gather from your answers, you don't think it's possible. I would have to have a static instantiator method like:public static java.sql.Date createDate (int year, int month, int date) { ... } OR public static java.sql.Date createDate (String dateString) { ... }Is that correct?
    If it is, I have to go back to the drawing board since it breaks my constructor paradigm for all of my 20 or so other MySQL column objects and, well, that's not acceptable, so I might just keep my deprecations for now.
    -G

  • How To Add Days into a Date from java.util.Date class

    I have a problem when i wants to add 2 or days into a
    date object geting by java.util.Date class. so please help me resolve this issue?
    for e.g i have a date object having 30/06/2001,
    by adding 2 days i want 02/07/2001 date object ?
    Code
    public class test2
    public static void main(String args[])
    java.util.Date postDate = new java.util.Date();
    myNewDate = postDate /* ?*/;
    Here i want to add 2 date into postDate

    Use Calendar...
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.DAY, 2); // I'm not sure about that "DAY"

  • Error:Class java.util.date not found

    i have installed 9iAS on my computer.And i want to develop program on JSP.i tried the url below
    http://eyuksel/servlet/IsItWorking
    and i got "it is working" message.when i try to execute my first jsp file i get the error:
    Errors compiling:d:\ias\apache\apache\htdocs\_pages\\_first.java
    d:\ias\apache\apache\htdocs\_pages\_first.java:55: Class java.util.date not found.
    out.print( new java.util.date() );
    ^
    1 error
    what must i do or how can i install the java classes.
    kind regards...
    null

    Thank you very much.It worked:)
    Java is case-sensitive.
    try
    java.util.Date
    instead of
    java.util.date
    null

  • What's wrong with java.util.Date??

    Hi all,
    I was just practicing a bit of java.util ,when i was compiling my code-
    import java.util.Date;
    import java.text.SimpleDateFormat;
    class DateStamp{
    public static void Main(String args[]){
    doDate1;
    String D;
    int D1,D2,D3;
    Date dt=new Date();
    SimpleDateFormat sdf=new SimpleDateFormat("dd-mm-yyyy");
    /*When using method .setDate(x) ,is x an integer or String?can x=2/5/2002 or 2-5-2002?*/
    public void doDate1{
    dt.setDay(12);
    dt.setMonth(12);
    dt.setYear(102);
    D=dt.getTime();
    D.parseInt(D1);D=""
    D=sdf.getTime();
    D.parseInt(D2);
    int D3=D2-D1;
    int D3=D3/86400000;/*How do you convert milisec-to-days?*/
    D=D3.toString().
    System.out.println(D+"days have elapsed since then");
    the compiler said this-
    File Compiled...
    --------------------------- Javac Output ---------------------------
    DateStamp.java:7: Invalid expression statement.doDate1;^DateStamp.java:14: Instance variables can't be void: doDate1public void doDate1; ^2 errors
    this problem is persistant, and i'm a java newbie ,Does anyone know what's wrong here?
    Thanks!
    Regards,
    aesh83

    How do you get System date onto a Date variable?Calendar.getInstance().getTime() returns a java.util.Date for the current time. You can also use System.currentTimeMillis() and turn it into a Date.
    Will date.after(Date when) method work when Date
    variables are in milisecs?Date.after(Date when) compares two date objects. As the JavaDoc says "Returns:
    true if and only if the instant represented by this Date object is strictly later than the instant represented by when" To me that says that milliseconds are taken into account, I.E. comparing dates actually compares the date plus the time portion.
    >
    What methods-
    *Convert a date(dd/mm/yy) to milisec?If you look in the javaDoc you'll see "long getTime() Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object." Calendar also has the getTimeInMillis() method.
    *Convert a milisec value to a date(dd/mm/yy)?Calendar.setTimeInMillis(long);
    I'm have this little problem.
    When using GregorianCalander-
    *need to initialize?
    *need set today's date?Calendar.getInstance() will return an appropriate Calendar object for the current locale initialized to the current date/time.
    *how do you check if a date exceeds 3 weeks?I'm not sure what you mean. There are a couple of roll(...) methods that will allow you to add a unit of time to a date. I.E. you could add three weeks to a date.
    To ignore the time portion of a date just set the time to "00:00"
    Col

  • Converting Java.util date to XML date in format YYYY-MMM-dd

    I'm using below code to convert java.util.date to XML date
    public static XMLGregorianCalendar toXMLDate(Date dte) {
       try {
       // this may throw DatatypeConfigurationException
       DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
       GregorianCalendar calendar = new GregorianCalendar();
       // reset all fields
      calendar.clear();
       Calendar parsedCalendar = Calendar.getInstance();
      parsedCalendar.setTime(dte);
      calendar.set( parsedCalendar.get(Calendar.YEAR ),
      parsedCalendar.get(Calendar.MONTH),
      parsedCalendar.get(Calendar.DATE ));
       XMLGregorianCalendar xmlCalendar = datatypeFactory.newXMLGregorianCalendar( calendar );
      xmlCalendar.setTimezone( DatatypeConstants.FIELD_UNDEFINED );
      xmlCalendar.setFractionalSecond( null );
       return xmlCalendar;
    I need to get the date in the format YYYY-MMM-dd, but it returns in a format YYYY-MM-dd. Can anyone tell me how can i change the format? Thanks

    >
    The snippet of ApplicationClient where the assignment took place and the syntax occurred were:
    1. DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    2. DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
    3. Date date = new Date();
    4. CustomerDetail customerDetail = new CustomerDetail();
    5. customerDetail.setCollectionDate(dateFormat.format(date)); //got the above syntax error
    6. customerDetail.setCollectionTime(timeFormat.format(date)); //got the above syntax error
    .....I am running JDK 1.6.0_10, Glassfish v2r2, MySQL 5.0, Netbeans 6.1 on Windows XP platform.The format method returns a String not a Date. Why not just store the Date as is without formatting, and format it when you want to retrieve it from the DB and display it?
    m

  • How to change a date value from "java.util.Date" to "java.sql.Date"?

    Hi all,
    How to change a date value from "java.util.Date" to "java.sql.Date"?
    I m still confusing what's the difference between them.....
    thanks
    Regards,
    Kin

    Thanks
    but my sql statement can only accept the format (yyyy-MM-dd)
    such as "select * from xx where somedate = '2004-12-31'
    but when i show it to screen, i want to show it as dd-MM-yyyy
    I m using the following to change the jave.util.Date to str and vice versa. But it cannot shows the dd-MM-yyyy. I tried to change the format from yyyy-MM-dd to dd-MM-yyyy, it shows the wrong date in my application.
         public String date2str(java.util.Date thisdate)     {
              if (thisdate != null)     {
                   java.sql.Date thissDate = new java.sql.Date(thisdate.getTime());
                   return date2str(thissDate);
              }     else     {
                   return "";
         public String date2str(java.sql.Date thisdate)     {
              if (thisdate != null)     {
                   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                   return sdf.format(thisdate);
              }     else     {
                   return "";
         public java.util.Date str2date(String thisdate)     {
              String dateFormat = "yyyy-MM-dd"; // = 1998-12-31
              java.util.Date returndate = null;
              if (thisdate != null)     {
                   SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
                   try {
                        returndate = dateFormatter.parse(thisdate);
                   } catch (ParseException pe) {
                        System.out.println (pe.getMessage());
              return returndate;
         }

  • Convert java.util.Timestamp to a formatted java.util.date

    Hi,
    I am trying to convert a java.util.TimeStamp date from the DB to a formatted date object. So, how can I convert this TimeStamp into an hourly or daily format that will return me a java.util.Date object? I was trying to convert the TimeStamp using SimpleDateFormat and then parse out to a Date object, but this isn't working. This is what I need
    TimeStamp converted to an "Hourly" date object --> 12:00pm
    TimeStamp converted to a "Monthly" date object --> May

    Hi,
    I am trying to convert a java.util.TimeStamp date
    from the DB to a formatted date object. I don't know what a "formatted date object" is. Do you mean a String?
    So, how can
    I convert this TimeStamp into an hourly or daily
    format that will return me a java.util.Date object?I don't know what you mean when you say "...int an hourly or daily format that will return me a java.util.Date object". A format is a String, are you wanting to parse that into a java.util.Date object?
    I was trying to convert the TimeStamp using
    SimpleDateFormat and then parse out to a Date
    object, but this isn't working. This is what I
    need
    TimeStamp converted to an "Hourly" date object -->
    12:00pmThat's a String then?
    A java.sql.Timestamp extends java.util.Date. So if you've a Timestamp, then you can use it as you would a java.util.Date. If you want a String, then as you say use SimpleDateFormat with the appropriate format string.
    Good Luck
    Lee

Maybe you are looking for