Infolinks In Text Ads

Sep 9, 2010

get System Time in java code Example

How to get System Time in java code Example.

public static String getSystemTime()
    {
        DateFormat df = DateFormat.getTimeInstance(3);
        df.setTimeZone(TimeZone.getDefault());
        String sec = new String("" + df.getCalendar().get(13));
        String min = new String("" + df.getCalendar().get(12));
        String hr = new String("" + df.getCalendar().get(11));
        if(sec.length() < 2)
            sec = "0" + sec;
        if(min.length() < 2)
            min = "0" + min;
        if(hr.length() < 2)
            hr = "0" + hr;
        String currentTime = hr + ":" + min + ":" + sec;
        return currentTime;
    }

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...