Skip to content

Commit f213a7e

Browse files
committed
Displaying Date and Time
1 parent 769bb63 commit f213a7e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

date-time.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.text.*;
2+
import java.util.*;
3+
class datetime {
4+
public static void main(String args[])
5+
{
6+
SimpleDateFormat formatDate = new SimpleDateFormat(
7+
"dd/MM/yyyy HH:mm:ss z");
8+
9+
Date date = new Date();
10+
// initialize "Date" class
11+
12+
formatDate.setTimeZone(TimeZone.getTimeZone("IST"));
13+
// converting to IST or format the Date as IST
14+
15+
System.out.println(formatDate.format(date));
16+
// print formatted date and time
17+
}
18+
}

0 commit comments

Comments
 (0)