Java SQL Timestamp after() function with examples Last Updated : 06 Mar, 2019 Comments Improve Suggest changes Like Article Like Report The after() function is a part of Timestamp class of Java SQL.The function returns a boolean value representing whether the Timestamp object occurs after the given Timestamp object . Function Signature: public boolean after(Timestamp t) Syntax: ts1.after(ts2); Parameters: The function accepts Timestamp object as parameter which is to be checked. Return value: The function returns boolean data type representing whether the Timestamp object occurs after the given Timestamp object. Exception: The function does not throw any exceptions Below examples illustrate the use of after() function Example 1: Create two non equal timestamps and check whether the second timestamp occurs after first timestamp or not Java // Java program to demonstrate the // use of after() function import java.sql.*; public class solution { public static void main(String args[]) { // Create two timestamp objects Timestamp ts1 = new Timestamp(10000); Timestamp ts2 = new Timestamp(10001); boolean b = ts2.after(ts1); // Check if the second timestamp occurs // after first timestamp if (b) { // If true print that the Second Timestamp // occurs after the first timestamp System.out.println("Second Timestamp occurs" + " after first timestamp"); } else { // If false print that the Second Timestamp // does not occur after the first timestamp System.out.println("Second Timestamp does not" + " occur after first timestamp"); } } } Output: Second Timestamp occurs after first timestamp Example 2: Create two equal timestamps and check whether the second timestamp occurs after first timestamp or not Java // Java program to demonstrate the // use of after() function import java.sql.*; public class solution { public static void main(String args[]) { // Create two timestamp objects Timestamp ts1 = new Timestamp(10000); Timestamp ts2 = new Timestamp(10000); boolean b = ts2.after(ts1); // Check if the second timestamp occurs // after first timestamp if (b) { // If true print that the Second Timestamp // occurs after the first timestamp System.out.println("Second Timestamp occurs" + " after first timestamp"); } else { // If false print that the Second Timestamp // does not occur after the first timestamp System.out.println("Second Timestamp does not" + " occur after first timestamp"); } } } Output: Second Timestamp does not occur after first timestamp Reference: https:// docs.oracle.com/javase/7/docs/api/java/sql/Timestamp.html Comment More infoAdvertise with us Next Article Java SQL Timestamp after() function with examples A andrew1234 Follow Improve Article Tags : Java Java-Functions Java-Sql package Java-TimeStamp Practice Tags : Java Similar Reads Java SQL Timestamp before() function with examples The before() function is a part of Timestamp class of Java SQL.The function returns a boolean value representing whether the Timestamp object occurs before the given Timestamp object. Function Signature: public boolean before(Timestamp t) Syntax: ts1.before(ts2); Parameters: The function accepts Tim 2 min read Java SQL Timestamp getTime() function with examples The getTime() function is a part of Timestamp class of Java SQL.The function is used to get the time of the Timestamp object. The function returns time in milliseconds which represents the time in milliseconds after 1st January 1970. Function Signature: public long getTime() Syntax: ts1.getTime(); P 2 min read Java SQL Timestamp setTime() function with examples The setTime() function is a part of Timestamp class of Java SQL.The function is used to set the time of the Timestamp object. The function takes time in milliseconds which represents the time in milliseconds after 1st January, 1970. Function Signature: public void setTime(long t) Syntax: ts1.setTime 2 min read Java SQL Timestamp setNanos() function with examples The setNanos() function is a part of Timestamp class of Java SQL.The function is used to set the fractional part of the second's value of the Timestamp Object. The function sets the object's Nanos value to the given value.Function Signature: public void setNanos(int t) Syntax: ts1.setNanos(l); Param 2 min read Java SQL Timestamp getNanos() function with examples The getNanos() function is a part of Timestamp class of Java SQL.The function is used to get the fractional part of the seconds value of the Timestamp Object. The function returns the object's nanos value . Function Signature: public int getNanos() Syntax: ts1.getNanos(); Parameters: The function do 2 min read Like