Java SQL Date setSeconds() MethodThe setSeconds() method of Java Date class sets the value of Second by overwriting the value of second represented by this date. This method should not be used because SQL date values do not have a time component and this method is deprecated too. This method overrides setSeconds in class Date. SyntaxParametersi = It is the Second value ReturnsIt sets the value of the second. ExceptionIllegalArgumentException is thrown if this method is invoked. ExampleTest it NowOutput: !! this output is shown by using java.util.Date as an alternate to deprecated method java.sql.Date Current time in Seconds = 21 !! this output is shown by using java.sql.Date and proves why this method is deprecated and we can't access time components in java.sql.Date class. Exception in thread "main" java.lang.IllegalArgumentException at java.sql/java.sql.Date.setSeconds(Unknown Source) at date.JavaDateExample1.main(JavaDateExample1.java:24)
Next TopicJava SQL Date
|