MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

SQL

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The class java.sql.Timestamp has its super class as
A
java.sql.Time
B
java.util.Date
C
java.util.Time
D
None of the above
Explanation: 

Detailed explanation-1: -TimeStamp has the super class as Date which represents a specific instant in time, with millisecond precision. It allows the date to include year, month, day, hour, minute, and second values. It also allowed the formatting and parsing of date strings.

Detailed explanation-2: -Program to convert Timestamp to Date in Java The code to convert Timestamp into a java. util. Date is inside main() method, you can see it’s quite simple, just take the long millisecond value by calling getTime() on Timestamp and pass it to Date constructor, that’s it, you are done.

Detailed explanation-3: -The date from util package has is a combination of date and time while the Date from SQL package only represents only Date part. To be precise Date contains the year, month, and day information while Time means hour, minute, and second information.

Detailed explanation-4: -A Timestamp also provides formatting and parsing operations to support the JDBC escape syntax for timestamp values. The precision of a Timestamp object is calculated to be either: 19, which is the number of characters in yyyy-mm-dd hh:mm:ss. 20 + s, which is the number of characters in the yyyy-mm-dd hh:mm:ss.

There is 1 question to complete.