Javatpoint Logo
Javatpoint Logo


The java.sql.Date class represents only date in java. It inherits java.util.Date class.

The java.sql.Date instance is widely used in JDBC because it represents the date that can be stored in database.

Some constructors and methods of java.sql.Date class has been deprecated. Here, we are not giving list of any deprecated constructor and method.

java.sql.Date Constructor

1)Date(long milliseconds)Creates a sql date object for the given milliseconds since January 1, 1970, 00:00:00 GMT.

java.sql.Date Methods

1)void setTime(long time)changes the current sql date to given time.
2)Instant toInstant()converts current sql date into Instant object.
3)LocalDate toLocalDate()converts current sql date into LocalDate object.
4)String toString()converts this sql date object to a string.
5)static Date valueOf(LocalDate date)returns sql date object for the given LocalDate.
6)static Date valueOf(String date)returns sql date object for the given String.

java.sql.Date Example: get current date

Let's see the example to print date in java using java.sql.Date class.

Test it Now



Java String to java.sql.Date Example

Let's see the example to convert string into java.sql.Date using valueOf() method.

Test it Now


Next TopicJava Calendar

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA