The java.time, java.util, java.sql and java.text packages contains classes for representing date and time. So, you need to convert Timestamp object into long value using getTime() method of java.sql.Timestamp class.. Let's see the constructor of Date class and signature of getTime() method. how to subtract minutes from current time in java, java subtract hours, minutes and seconds from java date time with example program. Before Java 8, the standard Java approach for dates and times was via the Date and Calendar classes and the standard approach to parsing and formatting dates was via DateFormat and SimpleDateFormat. 1. It begins with creating an instance of the Date object:This returns an instance of the Date object in the variabled using the current date and time. it will reduce your string length and you will get only date part. DateTimeFormatter (Java 8) Convert the String to LocalDateTime and change the date format with DateTimeFormatter java.util.Date is definitely the most common time-related class.