[Opensource] Formatting dates

Mike Traum mtraum at cirnetwork.org
Fri Apr 11 12:11:52 PDT 2003


I don't use SQL Server, so this is just a guess, but it looks like the
dateUpdateFormat you (and the Expresso docs) are using is wrong. Everything
I've seen shows SQL Server as "yyyy-MM-dd". Give that a try - if it doesn't
work, post the stack trace (and maybe some logging).

mike

     -----Original Message-----
     From: DComeau at xenos.com [mailto:DComeau at xenos.com]
     Sent: Thursday, April 10, 2003 8:53 PM
     To: opensource at jcorporate.com
     Subject: [Opensource] Formatting dates
     
     
     
     Hi all,
     
     I'm having trouble with getting my date fields inserted 
     into my database
     
     /********************/
     
     // Piece the data together
     boolean dateProvided = (!formSuspendDateMonth.equals("") && 
         !formSuspendDateDay.equals("") && 
     !formSuspendDateYear.equals(""));
     
     
     String suspendDate = "";            
     
     //Verify dates.            
     try {
         if (dateProvided) {
             suspendDate =
     DateTime.getDateForDB(Integer.parseInt(formSuspendDateYear), 
      
     Integer.parseInt(formSuspendDateMonth),
      
     Integer.parseInt(formSuspendDateDay));
         }
     }
     catch (Exception e) {
         response.addError("Suspend date is invalid, please correct and
     resubmit.");
         transition("PromptSubscriptionProfile", request, response);
         return;
     }
     
     /********************/
     
     
     I thought using DateTime.getDateForDB() would work but it 
     doesn't seem to. I
     don't get an exception, but when I use the value I get a 
     DBException when I
     add the record.
     
     The value I get comes out like this: 01-02-2003
     
     
     
     Here's part of my expresso config:
     
     ------------------------------------
     
     <jdbc driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"
      
     url="jdbc:microsoft:sqlserver://myserver:1433;databaseName=
     DBNAME;SelectMeth
     od=cursor"
           connectFormat="1"
           login="myUsername"
           password="myPassword"
           dateSelectFormat="dd-MM-yyyy"
           dateUpdateFormat="dd-MM-yyyy"
           dateTimeSelectFormat="yyyy-MM-dd HH:mm:ss"
           dateTimeUpdateFormat="yyyy-MM-dd HH:mm:ss"
           cache="y" createTableIndicies="true"
           limitationPosition="" skipText="true"
      
     escapeHandler="com.jcorporate.expresso.core.db.DoubleQuoteE
     scapeHandler">
     _______________________________________________
     Opensource mailing list
     Opensource at jcorporate.com
     http://mail.jcorporate.com/mailman/listinfo/opensource
     Archives: http://mail.jcorporate.com/pipermail/opensource/
     



More information about the Opensource mailing list