A java.util.Date is not a java.sql.Date. It's the other way around. A java.sql.Date is a java.util.Date.
You'll need to convert it to a java.sql.Date by using the constructor that takes a long that a java.util.Date can supply.
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
Answer from rgettman on Stack Overflow Top answer 1 of 11
113
A java.util.Date is not a java.sql.Date. It's the other way around. A java.sql.Date is a java.util.Date.
You'll need to convert it to a java.sql.Date by using the constructor that takes a long that a java.util.Date can supply.
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
2 of 11
58
These are all too long.
Just use:
new Date(System.currentTimeMillis())
Videos
02:01
How to Get java.sql.Date in a Specific Format - YouTube
15:41
Write a Java program to demonstrate SQL Date (Core Java Interview ...
02:48
java.sql.Date class Introduction | Java Date and Time | Date and ...
What is the difference Between java util Date and java sql ...
06:46
SQL Tutorial #29 - Date and Time Functions in SQL - YouTube
05:55
How to Convert java util Date to java sql Date in Java - YouTube
Oracle
docs.oracle.com › javase › 8 › docs › api › java › sql › Date.html
Date (Java Platform SE 8 )
October 20, 2025 - Java™ Platform Standard Ed. 8 ... A thin wrapper around a millisecond value that allows JDBC to identify this as an SQL DATE value.
TutorialsPoint
tutorialspoint.com › how-do-i-create-a-java-sql-date-object-in-java
How do I create a java.sql.Date object in Java?
February 5, 2021 - import java.sql.Date; public class Demo { public static void main(String args[]) { String str = "2017-12-03"; Date date = Date.valueOf(str); System.out.println("Date Value: "+date); } }
W3Schools
w3schools.com › java › java_date.asp
Java Date and Time
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
Oracle
docs.oracle.com › en › java › javase › 22 › docs › api › java.sql › java › sql › Date.html
Date (Java SE 22 & JDK 22)
July 16, 2024 - Creates a LocalDate instance using the year, month and day from this Date object. ... This method always throws an UnsupportedOperationException and should not be used because SQL Date values do not have a time component.
Baeldung
baeldung.com › home › java › java dates › java.util.date vs java.sql.date
java.util.Date vs java.sql.Date | Baeldung
January 8, 2024 - It also doesn’t handle all dates very well. Technically, it should reflect coordinated universal time (UTC). However, that depends on an operating system of the host environment. Most modern operating systems use 1 day = 24h x 60m x 60s = 86400 seconds, which as we can see, doesn’t take the “leap second” into account. With the introduction of Java 8, java.time package should be used. Prior to Java 8, an alternative solution was available – Joda Time. The java.sql.Date extends java.util.Date class.
Oracle
docs.oracle.com › javase › 7 › docs › api › java › sql › Date.html
Date (Java Platform SE 7 )
Constructs a Date object using the given milliseconds time value. If the given milliseconds value contains time information, the driver will set the time components to the time in the default time zone (the time zone of the Java virtual machine running the application) that corresponds to zero GMT.
GeeksforGeeks
geeksforgeeks.org › java › how-to-convert-java-util-date-to-java-sql-date-in-java
How to Convert java.util.Date to java.sql.Date in Java? - GeeksforGeeks
July 23, 2025 - Date class of java.util package is required when data is required in a java application to do any computation or for other various things, while Date class of java.sql package is used whenever we need to store or read the data of DATE type in SQL, also Date class of java.sql package stores ...
Dariawan
dariawan.com › tutorials › java › java-sql-date-java-sql-time-and-java-sql-timestamp
java.sql.Date, java.sql.Time, and java.sql.Timestamp | Dariawan
August 15, 2019 - As in above example, with setObject(int parameterIndex , x Object); we can just give a util.Date to the last three parameters which accept it without problem (this is also happen in another JDBC driver, not only MySQL). But to just use setObject(...) lazily can cause some problem, including data (or part of data) loss. Note: The URL suffix ?serverTimezone=Asia/Singapore is to suppress: Exception in thread "main" java.sql.SQLException: The server time zone value 'Malay Peninsula Standard Time' is unrecognized or represents more than one time zone.
Coderanch
coderanch.com › t › 775227 › java › Datetime-format-sql-server
Datetime format for sql server (Beginning Java forum at Coderanch)
July 7, 2023 - Is there a already existing class ...686436900) to look like the DATETIME format (DATETIME - format: YYYY-MM-DD HH:MI:SS) ? Basically something like : 2005-07-30 23:59:59.000 ... There must be; you can doubtless change the java.sql.Date object to a LocalDate....
University of Washington
courses.cs.washington.edu › courses › cse341 › 98au › java › jdk1.2beta4 › docs › api › java › sql › Date.html
Class java.sql.Date
java.lang.Object | +--java.util.Date | +--java.sql.Date
Medium
devdeejay.medium.com › working-with-sql-dates-in-java-mini-tutorial-for-beginners-4ce17af38b17
Working With SQL Dates in Java : Mini Tutorial For Beginners | by Dhananjay Trivedi | Medium
September 5, 2018 - Although, many of the methods of java.util.Date has been deprecated so don’t be too dependent on it while working with Dates. LocalDate class in Java 8 is a much more Thread safe, dependable option. I will be adding codes working with LocalDate very soon. ... Default Format Of Our SQL date is : 2018-09-04 Util Date : 2018-09-04 New Format : 04-09-2018 SQL Date As String : 2018-09-04 New Formatted Util Date : Tue Sep 04 00:00:00 IST 2018
Coderanch
coderanch.com › t › 300652 › databases › java-sql-Date-Oracle-DateFormating
java.sql.Date, Oracle - DateFormating? (JDBC and Relational Databases forum at Coderanch)
If you are trying to get that date and store it into the "userdate" column, then you should not have to worry about the format if you are using a PreparedStatement. For example, you should be able to do something like this: Now, if you are trying to build an sql string and use a generic Statement to execute it, then you do have to format the date into a String first.