-->
Skip to main content

Posts

Showing posts from July, 2021

Convert String to sql date in java 8 [2021]

Convert String to SQL date in java 8 [2021] In this tutorial, we will see how to convert string to SQL date in Java 8 with an example using the SQL Date class method. Contents Java SQL Date Example: Get Current Date String to SQL date in java 8 Conclusion References Java SQL Date Example: Get Current Date Let's see an example of how to get the current date using java SQL date. Example: import java.sql.Date; public class SqlDateExample { public static void main(String[] args) { long milliseconds = System.currentTimeMillis(); Date currentDate = new Date(milliseconds); System.out.println(currentDate); } } Output: 2021-07-23 String to SQL date in java 8 To Convert Java String to SQL date we will use java.sql.Date.valueOf(String s) method.  Example: import java.sql.Date; public class StringToSqlDate { public static void main(String[] args) { String stringDate = "2021-07-23"; System.out.println("String format date : "