Time Class: Java - Lang.object Java - Util.date
Time Class: Java - Lang.object Java - Util.date
Class java.sql.Time
java.lang.Object
|
+--java.util.Date
|
+--java.sql.Time
This class is a thin wrapper around java.util.Date that allows JDBC to identify this as a SQL
TIME value. It adds formatting and parsing operations to support the JDBC escape syntax for
time values.
Date Class:
The class Date represents a specific instant in time, with millisecond precision. The Date class of
java.util package implements Serializable, Cloneable and Comparable interface. It provides
constructors and methods to deal with date and time with java.
Constructors
Methods
boolean after(Date date) : Tests if current date is after the given date.
boolean before(Date date) : Tests if current date is before the given date.
int compareTo(Date date) : Compares current date with given date. Returns 0 if the
argument Date is equal to the Date; a value less than 0 if the Date is before the Date
argument; and a value greater than 0 if the Date is after the Date argument.
long getTime() : Returns the number of milliseconds since January 1, 1970, 00:00:00
GMT represented by this Date object.
void setTime(long time) : Changes the current date and time to given time.
Calender Class
Java Calendar class is an abstract class that provides methods for converting date between a
specific instant in time and a set of calendar fields such as MONTH, YEAR, HOUR, etc. It
inherits Object class and implements the Comparable interface.
Declaration
public abstract class Calendar extends Object
Example:
import java.util.Calendar;
public class CalendarExample1 {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();