+ 8

Get Dates

Hi! I don't have code to show yet. But what i want is: to pick date in format "dd-MM-yyyy HH:mm " for example i pick 12.10.2018 10:40 and i want to see the next date after x hours (for example the date after 48h so it will be 14.10.2018 10:40) how can i do it?

19th Dec 2018, 12:44 PM
Mateusz Legend
Mateusz Legend - avatar
5 Answers
19th Dec 2018, 1:44 PM
LukArToDo
LukArToDo - avatar
+ 20
One way: import java.time.LocalDateTime; import java.time.Period; public class Program { public static void main(String[] args){ LocalDateTime date = LocalDateTime.of( 2018, 12, 19, 14, 38, 00); System.out.print( date.plus(Period.ofDays(2))); } } Works with hours as well: import java.time.Duration; ... date.plus(Duration.ofHours(48)));
19th Dec 2018, 1:39 PM
Tashi N
Tashi N - avatar
+ 7
Check the following code : https://code.sololearn.com/c6VKfiKw1Nfe/#java What do you mean pick a date ? as an input string ?
19th Dec 2018, 1:31 PM
Prokopios Poulimenos
Prokopios Poulimenos - avatar
+ 5
Thanks Will check all of those you send me :)
19th Dec 2018, 1:47 PM
Mateusz Legend
Mateusz Legend - avatar
0
Hello
21st Dec 2018, 8:10 AM
Š¢ŠøŠ¼Š¾Ń„ŠµŠ¹ ŠšŠ¾Ń‡ŠµŃ€Š³ŠøŠ½
Š¢ŠøŠ¼Š¾Ń„ŠµŠ¹ ŠšŠ¾Ń‡ŠµŃ€Š³ŠøŠ½ - avatar