java.sql.Date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veremue
    New Member
    • Mar 2007
    • 14

    #1

    java.sql.Date

    How can I set the current date in the format 2007-06-06 for java.sql.Date?
  • DeMan
    Top Contributor
    • Nov 2006
    • 1799

    #2
    search java calendar on the net.....it should explain lots

    Comment

    • veremue
      New Member
      • Mar 2007
      • 14

      #3
      Originally posted by DeMan
      search java calendar on the net.....it should explain lots

      thank you I have done so. i have a small issue now. the following code segment is producing a wrong date on the year.

      code: java

      int year = cal.get(Calenda r.YEAR);
      int month = cal.get(Calenda r.MONTH);
      int day = cal.get(Calenda r.DAY_OF_MONTH) ;

      ....

      I am setting the date as below:

      preqL.setReceip tDate(new java.sql.Date(y ear,month,day)) ;//preqL is a local object

      when I print it in the jsp it shows:: 3907-06-07 instead of 2007-06-07

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by veremue
        thank you I have done so. i have a small issue now. the following code segment is producing a wrong date on the year.

        code: java

        int year = cal.get(Calenda r.YEAR);
        int month = cal.get(Calenda r.MONTH);
        int day = cal.get(Calenda r.DAY_OF_MONTH) ;

        ....

        I am setting the date as below:

        preqL.setReceip tDate(new java.sql.Date(y ear,month,day)) ;//preqL is a local object

        when I print it in the jsp it shows:: 3907-06-07 instead of 2007-06-07
        How did you set the date?
        use setReceiptDate( Date.valueOf(st ringDate)) to set the date.

        Comment

        • DeMan
          Top Contributor
          • Nov 2006
          • 1799

          #5
          Originally posted by veremue
          when I print it in the jsp it shows:: 3907-06-07 instead of 2007-06-07
          1) follow R0's advice
          2) sounds like the date you used only wants # of years after 1900 ie 107......

          Comment

          Working...