Print Time Example Java Program
Syntax
GregorianCalendar Variable_name1 = new GregorianCalendar(); Variable_name2 = date.get(Calendar.SECOND); Variable_name3 = date.get(Calendar.MINUTE); Variable_name4 = date.get(Calendar.HOUR);
Print Time Example Program
import java.util.*; class PrintTime{ public static void main(String args[]){ int day, month, year; int second, minute, hour; GregorianCalendar date = new GregorianCalendar(); second = date.get(Calendar.SECOND); minute = date.get(Calendar.MINUTE); hour = date.get(Calendar.HOUR); System.out.println("Current time is "+hour+" : "+minute+" : "+second); } }
Sample Output
Output is: Current time is 1 : 2 : 28
Miscellaneous Programs
- Super Keyword Example Java Program
- This Keyword Example Java Program
- Sleep Function Example Java Program
- IP Address Example Java Program
- Print Date Example Java Program
- Print Time Example Java Program
- Print Week Example Java Program
- User Defined Package Example Java Program
- Command Line Arguments Example Java Program
Read More Articles
- Multiple Inheritance Using Interface Example Java Program
- Single Inheritance Example Java Program
- Multilevel Inheritance Example Java Program
- Hierarchical Inheritance Example Java Program
- Find all Substrings of a given string Example Java Program
- Create Matrix Example Java Program
- Sum Of Three Numbers Example Java Program
- Twin Prime Example Java Program
- Heap Sort Example Java Program
- Compile Time Polymorphism Example Java Program