JAVA SP T


Lets dive into snapshot of my programs!💻

23.How to convert Date to Timestamp.

💡Code:

import java.sql.Timestamp;
                import java.util.Date;
                
                public class DateToTimestampConversion7078 {
                    public static void main(String[] args) {
                        // Example Date
                        Date dateValue = new Date();
                
                        // Convert Date to Timestamp
                        Timestamp timestampValue = new Timestamp(dateValue.getTime());
                
                        // Print the converted Timestamp value
                        System.out.println("Converted Timestamp value: " + timestampValue);
                    }
                }
                
           

📸Output :

output