-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment221.java
More file actions
42 lines (23 loc) · 863 Bytes
/
Assignment221.java
File metadata and controls
42 lines (23 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package TestNGCLAssignments;
import java.util.Date;
import org.testng.annotations.Test;
//WAP to utilize Date & Time Concept?
public class Assignment221 {
@Test
public void Date_Time() {
Date d1 = new Date();
// System.out.println(d1.getTime());
Date d2 = new Date(d1.getTime() + (1000 * 60 * 60 * 24 * 3));
System.out.println(d2);
String FutherTime = d2.toString();
System.out.println(FutherTime);
String Year = FutherTime.substring(FutherTime.length() - 4);
System.out.println(Year); // only year will be displayed
String month = FutherTime.substring(4, 7); // only month will be displayed
System.out.println(month);
String time = FutherTime.substring(10, 18); // only time will be displayed
System.out.println(time);
String StringFormat = time.concat(month).concat(Year);
System.out.println(StringFormat);
}
}