Java SQL Date valueOf(String s) MethodThe valueOf(String s) method of Java Date class converts a string in JDBC date escape format to a Date value. SyntaxParameterss - It is a String object which represents a date in yyyy-[m]m-[d]d format. The leading zero for mm and dd may also be omitted. ReturnsThis method returns a java.sql.Date object which represents the given date. Example 1Test it NowOutput: Date = 1997-03-10 Java SQL Date valueOf(LocalDate date)The valueOf(LocalDate date) method of Java Date class returns a Date object. Here Date object is obtained from an instance of Date from a LocalDate object which has the same year, month and day of the month value as the given LocalDate. The Provided LocalDate is interpreted as the local date in the local time zone. SyntaxParametersdate - It is a LocalDate to convert. ReturnsThis method returns a Date object. ExceptionNUllPointerException is thrown if the date is null. Example 2Test it NowOutput: Value of Local Date: 2018-09-01 Value of SQL Date: 2018-09-01
Next TopicJava SQL Date
|