We can convert Timestamp to Date in java using constructor of java.util.Date class.
Approach: Current Time Stamp to Date
Java
import java.sql.Timestamp;import java.util.Date;public class TimestampToDate {public static void main(String[] args) {Timestamp stamp = new Timestamp(System.currentTimeMillis());Date date = new Date(stamp.getTime());System.out.println(date);}}
Approach: Giving Time Stamp to Date
Java
import java.util.Date;public class TimestampToDate {public static void main(String[] args) {long timestamp = 1617383733736l;Date d = new Date(timestamp);System.out.println(d);}}
No comments:
Post a Comment