Java SQL Date getSeconds() MethodThe getSeconds() method of Java Date class returns the number of seconds past the minute 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 getSeconds in class Date. SyntaxParametersNA ReturnsIt returns the number of seconds past the minute represented by this date. 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 = 51 !! 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.getSeconds(Unknown Source) at date.JavaDateExample1.main(JavaDateExample1.java:25)
Next TopicJava SQL Date
|