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.
🌐
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
🌐
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)
Hi Paul Clapham, Muhammad Saifuddin Thanks a lot for the response. Regards, Sandeep. ... Use SimpleDateFormat to set the format as you like.. DateFormat df=new SimpleDateFormat("dd-MMM-yyyy"); Date date=new Date(); String s=df.format(date); System.out.println(s);
🌐
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 ...
🌐
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".
🌐
Edureka
edureka.co › blog › date-format-in-java
Date Format In Java | Java Simple Date Format | Edureka
July 23, 2024 - To Convert the date to dd-mm-yyyy in Java, you use the Java—simpleDateFormat class. To write the dates in the dd-mm-yyyy format, you can use the Java—simpleDateFormat class.
🌐
Codedamn
codedamn.com › news › java
How do you convert java.util.Date to java.sql.Date in Java?
December 27, 2022 - If you have an application that needs to work with dates but doesn’t need full compliance with JDBC 3010 standards or other restrictions that apply when working with JDBC 4010. then this method will make it possible for you to do so without having any changes or incompatibilities between your code base and the database itself! ... import java.sql.*; import java.util.*; public class UseJavaSqlTimeStamp { public static void main(String[] args) { java.util.Date newdate = new java.util.Date(); java.sql.Timestamp byusingtimestamp = new java.sql.Timestamp(newdate.getTime()); System.out.println(newdate); System.out.println(byusingtimestamp); } } Code language: Java (java)