Skip to content

Commit 00d4ee9

Browse files
Add files via upload
This program tells us the live date and time. It is created in java......
1 parent 96bd46f commit 00d4ee9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

DateAndTime.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.*;
2+
3+
public class DateAndTime {
4+
public static void main(String[] args){
5+
int day, month, year;
6+
int second, minute, hour;
7+
8+
GregorianCalendar date = new GregorianCalendar();
9+
10+
day = date.get(Calendar.DAY_OF_MONTH);
11+
month = date.get(Calendar.MONTH);
12+
year = date.get(Calendar.YEAR);
13+
14+
second = date.get(Calendar.SECOND);
15+
minute = date.get(Calendar.MINUTE);
16+
hour = date.get(Calendar.HOUR);
17+
18+
System.out.println("Date is " + day + "/" + (month+1) + "/" + year);
19+
System.out.println("Time is " + hour + ":" + minute + ":" + second);
20+
}
21+
}

0 commit comments

Comments
 (0)