Pages

Get current hour

Complete source code below will print current computer hour in soldier time format.Soldier time format is 24 hour format.

>>Get current minute
>>Get current second
>>Get current computer time in java

**************************************************************
COMPLETE SOURCE CODE FOR : GetCurrentHour.java
**************************************************************


import java.util.Date;

public class GetCurrentHour
{
public static void main(String[]args)
{
Date myDate=new Date();

//Get current hour in soldier time format
int currentHour=myDate.getHours();

//Print current hour that we get
System.out.println("Current hour is : "+currentHour);
}
}


**************************************************************
JUST COMPILE AND EXECUTE IT
**************************************************************
Related Posts Plugin for WordPress, Blogger...