java.sql.Timestamp extends java.util.Date. You can do:

String s = new SimpleDateFormat("MM/dd/yyyy").format(myTimestamp);

Or to also include time:

String s = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(myTimestamp);
Answer from ChssPly76 on Stack Overflow
🌐
Oracle
docs.oracle.com › cd › E13222_01 › wls › docs › classdocs › java.sql.Date.html
Class java.sql.Date
This class is a thin wrapper around java.util.Date that allows JDBC to identify this as a SQL DATE value. It adds formatting and parsing operations to support the JDBC escape syntax for date values.
Discussions

How do I parse a String into java.sql.Date format?

Can't your SQL server accept strings for dates? The ones I've used can, so I just do something like:

String sqlDate = new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("dd-MM-yyyy").parse(startDate));

... and pass sqlDate to the parametrized query. Like konrad mentioned, lowercase 'mm' is for minutes, and uppercase 'MM' is for month, so I think that's where your problem was.

More on reddit.com
🌐 r/java
5
1
April 5, 2012
How can I format java.sql.Date ?
Find answers to How can I format java.sql.Date ? from the expert community at Experts Exchange More on experts-exchange.com
🌐 experts-exchange.com
June 4, 2008
[deleted by user]
Timestamp.valueOf(javalocaldatetimeobject) Java.sql.timestamp is only designed as transport format. You shouldn't use it anywhere out of the db layer... More on reddit.com
🌐 r/javahelp
5
3
July 19, 2015
Getting a date value from the database with JDBC
I checked it out - it's not how Postgres sends the date, psycopg2 in Python does it right: In [9]: c.execute('SELECT date FROM table ORDER BY date LIMIT 1;') In [10]: c.fetchall() Out[10]: [(datetime.date(2016, 6, 26),)] And there are numerous questions on StackOverflow. It seems JDBC is really bad at datetimes. More on reddit.com
🌐 r/Clojure
12
3
July 25, 2016
🌐
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....
🌐
Reddit
reddit.com › r/java › how do i parse a string into java.sql.date format?
r/java on Reddit: How do I parse a String into java.sql.Date format?
April 5, 2012 -

Alright, so I've got a file that I am reading and importing dates into a database using SQL. In order to do this, I need to parse the date from the file into a java.sql.Date. Here is an example date.

01-16-2014

And I need it in a format like

2014-01-16

I tried this.

String startDate="01-06-2014";
SimpleDateFormat sdf1 = new SimpleDateFormat("dd-mm-yyyy");
java.util.Date date = sdf1.parse(startDate);
java.sql.Date sqlStartDate = new java.sql.Date(date.getTime());

But I got an error saying that I couldn't parse a java.util.Date to a java.sql.Date through a method invocation. Is there an easy way to do this?

Thanks in advance for your help!

🌐
W3Schools
w3schools.com › java › java_date.asp
Java Date and Time
The ofPattern() method accepts all sorts of values, if you want to display the date and time in a different format. For example: ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
🌐
InfluxData
influxdata.com › home › java date format: a detailed guide
Java Date Format: A Detailed Guide | InfluxData
July 12, 2024 - It’s often used in JDBC programming to represent dates in SQL databases. The code below demonstrates the basic usage of java.sql.Date for working with dates in a JDBC context.
Find elsewhere
🌐
W3Schools
w3schools.com › sql › sql_dates.asp
Date Functions in SQL Server and MySQL
String Functions: ASCII CHAR_LENGTH CHARACTER_LENGTH CONCAT CONCAT_WS FIELD FIND_IN_SET FORMAT INSERT INSTR LCASE LEFT LENGTH LOCATE LOWER LPAD LTRIM MID POSITION REPEAT REPLACE REVERSE RIGHT RPAD RTRIM SPACE STRCMP SUBSTR SUBSTRING SUBSTRING_INDEX TRIM UCASE UPPER Numeric Functions: ABS ACOS ASIN ATAN ATAN2 AVG CEIL CEILING COS COT COUNT DEGREES DIV EXP FLOOR GREATEST LEAST LN LOG LOG10 LOG2 MAX MIN MOD PI POW POWER RADIANS RAND ROUND SIGN SIN SQRT SUM TAN TRUNCATE Date Functions: ADDDATE ADDTIME CURDATE CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURTIME DATE DATEDIFF DATE_ADD DATE_FORMAT DA
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › sql › Date.html
Date (Java Platform SE 8 )
October 20, 2025 - 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. ... date - milliseconds since January 1, 1970, 00:00:00 GMT not to exceed the milliseconds representation for the year 8099. A negative number indicates the number of milliseconds before January 1, 1970, 00:00:00 GMT. ... Converts a string in JDBC date escape format to a Date value.
🌐
Experts Exchange
experts-exchange.com › questions › 23457892 › How-can-I-format-java-sql-Date.html
Solved: How can I format java.sql.Date ? | Experts Exchange
June 4, 2008 - You mean you want to format it when you print it? ... java.sql.Date d = new java.sql.Date(System.currentTimeMillis()); String date = String.format("%tm/%<td/%<tY\n", d); System.out.println(date);
🌐
Baeldung
baeldung.com › home › java › java dates › convert java.util.date to java.sql.date
Convert java.util.Date to java.sql.Date | Baeldung
January 13, 2024 - SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); isoFormat.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles")); java.util.Date date = isoFormat.parse("2010-05-23T22:01:02"); TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); java.sql.Date sqlDate = new java.sql.Date(date.getTime()); System.out.println(sqlDate); // This will print 2010-05-23 TimeZone.setDefault(TimeZone.getTimeZone("Rome")); sqlDate = new java.sql.Date(date.getTime()); System.out.println(sqlDate); // This will print 2010-05-24 · For this reason, we might want to consider one of the conversion alternatives that we’ll examine in the next subsections. The first alternative to consider is to use the java.sql.Timestamp class instead of java.sql.Date.
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › data-types › date-transact-sql
date (Transact-SQL) - SQL Server | Microsoft Learn
The default string literal format, which is used for down-level clients, complies with the SQL standard form that is defined as yyyy-MM-dd. This format is the same as the ISO 8601 definition for DATE.
🌐
Coderanch
coderanch.com › t › 385771 › java › java-sql-Date-dd-mm
java.sql.Date to 'dd-mm-yyyy' format (Java in General forum at Coderanch)
Actually if you want something that's formatted as dd-mmm-yyyy it would have to be a String. A Date object doesn't have any format, it's just a date. Anyway to produce that String you should create a SimpleDateFormat object with the appropriate parameters, then call its format(Date) method ...
🌐
Dariawan
dariawan.com › tutorials › java › java-sql-date-examples
java.sql.Date Examples | Dariawan
July 24, 2019 - Date(long date): Constructs a Date object using the given milliseconds time value. ... import java.sql.Date; public class SqlDateInitExample { public static void main(String[] args) { long now = System.currentTimeMillis(); Date sqlDate = new ...
🌐
Codedamn
codedamn.com › news › java
How do you convert java.util.Date to java.sql.Date in Java?
December 27, 2022 - java.sql.Date: This class represents a date (year, month, and day) in the SQL format.
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-convert-java-sql-date-to-java-util-date-in-java
How to Convert java.sql.Date to java.util.Date in Java? - GeeksforGeeks
July 23, 2025 - // Java program to Convert ... utilDate = new java.util.Date(sqlDate.getTime()); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // converting the util date into string format final String stringDate ...
🌐
SAP Community
community.sap.com › t5 › technology-q-a › making-java-sql-date-dd-mm-yyyy-format › qaq-p › 6093745
Solved: making java.sql.Date dd.mm.yyyy format - SAP Community
September 7, 2009 - java.sql.Date format is m/d/yyyy. I must use dd.mm.yyyy format. How can it be done? Thanks. Help others by sharing your knowledge. Answer · Request clarification before answering. Comment · Show replies · Show replies · You must be a registered user to add a comment.
🌐
Medium
medium.com › codex › java-date-format-5a2515b07c2c
Java Date Format with Examples. java. util.Date | by Maneesha Nirman | CodeX | Medium
November 12, 2022 - A thin wrapper around a millisecond value allows JDBC to identify this as an SQL Date value. A milliseconds value represents the number of milliseconds that have passed since January 1, 1970, 00:00:00.000 GMT. This doesn’t keep any information about the time zone. and also it uses server or local time. This is inherited by util.Date class. ... With the introduction of Java 8, some constructors and methods got deprecated.
🌐
TutorialsPoint
tutorialspoint.com › format-date-with-simpledateformat-mm-dd-yy-in-java
Format date with SimpleDateFormat('MM/dd/yy') in Java
June 26, 2020 - A SimpleDateFormat object is used to format the current date (curDate) into different custom formats. The format() method is called with different date patterns, including custom ones like "yyyy/MM/dd", "dd-M-yyyy hh:mm:ss", and "dd MMMM yyyy zzzz".