We can make use of Timestamp and LocalDate classes to convert timestamp to date using the toLocalDate() method.
Example:
package org.code2care.examples;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;
/**
* Convert Date format from yyyy-MM-dd
* to dd/MM/yyyy example
* <p>
* author: Code2care.org
*/
public class Example {
public static void main(String... args) {
Timestamp timestamp = Timestamp.valueOf("2023-10-17 15:20:41");
LocalDate localDate = timestamp.toLocalDateTime().toLocalDate();
System.out.println("Timestamp: "+ timestamp);
System.out.println("LocalDate: " + localDate);
}
}
Output:

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!