Display local Time(Using Serializable Interface)

Display local Time(Using Serializable Interface)

Previous Home Next

 

Following program for display the local time by using Serializable interface.

 

 /*
* Save as a Time.java
* Program for Display local Time(Using Serializable Interface)
*/
package r4r.co.in;

import java.io.Serializable;
import java.util.*;

public class Time implements Serializable {

    private final Date date;

    public Time() {
        date = Calendar.getInstance().getTime();
        System.out.print("Local Time: " + date.toLocaleString()); //For local Time
    }

    protected Date getTime(Date time) {
        return time;
    }

    public static void main(String[] args) {
        Time t = new Time();      
    }
}

Local Time: 2 Feb, 2011 12:35:20 PM
Previous Home Next