JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.text.SimpleDateFormat;
import java.util.Date;
public class Program {
public static void main(String[] args) {
SimpleDateFormat sdf= new SimpleDateFormat("dd-MM-yyyy HH:mm");
int hours=48;
long hoursToMilisec=hours*60*60*1000;
Date current = new Date();
Date newDate= new Date(current.getTime()+hoursToMilisec);
System.out.println("Current time:" + sdf.format(current));
System.out.println("New time:" + sdf.format(newDate));
}
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run