Results 1 to 6 of 6
  1. #1
    Jack is offline Senior Member
    Join Date
    Jun 2007
    Posts
    130
    Rep Power
    0

    Default java.util.Date vs java.sql.Date

    what is the difference between java.util.Date and java.sql.Date?
    In which case do I have to use util.date and sql.date?
    why these two things are provided in java?

  2. #2
    bbq
    bbq is offline Senior Member
    Join Date
    Jun 2007
    Posts
    132
    Rep Power
    0

    Default

    Java.util.Date is a basic, all-purpose Date object. It simply stores a Date (as a long) and allows you to display it.

    java.sql.Date extends java.util.Date to add the following functionality:

    1) toString now outputs the date as "yyyy-mm-dd" instead of as a Locale specific String

    2) add the valueOf method to read a String of "yyyy-mm-dd" format and parse it into a sql.Date object.

  3. #3
    hariprashanth is offline Member
    Join Date
    Dec 2008
    Posts
    5
    Rep Power
    0

    Default

    The above information was helpful. Can we extract Time information from java.sql.Date api?

  4. #4
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Yes, the Java standard Date is really a DateTime. Its poorly named.

    And it is far harder to use than it should be. They layered in the Calendar classes in a fairly early version (java 1.2?) which made it less terrible to use if you are using western european GregorianCalendars. But its still far harder to use than it should be.

    And there are threading issues with some of the SimpleDateFormat classes.

    There is a replacement, JodaTime that is a clean design. It supports many more calendars (hebrew, islamic, etc.) and has a far more obvious API

    The whole java.sql.Date vs java.lang.Date thing is another example of hurried design and is a hack.

  5. #5
    cheapcarsauctions Guest

    Default Hello From Poland

    Hello to all ! Great site. I am new here greetings to all from Poland.

  6. #6
    ef_oren is offline Member
    Join Date
    Oct 2010
    Posts
    1
    Rep Power
    0

    Thumbs up java.sql.date is not a datetime

    it doesn't store the time , only the date value.
    it's different from java.util.date.

    (10x to semicolon)

Similar Threads

  1. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 05:15 PM
  2. java Date and Calendar
    By valoyivd in forum New To Java
    Replies: 1
    Last Post: 03-30-2008, 07:49 PM
  3. PreparedStatement with java.sql.Date
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-10-2008, 12:39 PM
  4. Using java.sql.Date
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-10-2008, 12:32 PM
  5. Java Date
    By levent in forum Java Tutorial
    Replies: 0
    Last Post: 08-05-2007, 02:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •