Last active
July 1, 2018 07:12
-
-
Save daler445/8e8161098d73d87d982bc1b82624a46b to your computer and use it in GitHub Desktop.
изменение даты на java / date changing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dateString = null; | |
String dtStart = "2018-06-23T16:52:13"; // before/до | |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH); // pattern/шаблон English locale/Английская локализация | |
try { | |
Date c_date = format.parse(dtStart); | |
Long newDate = c_date.getTime() + 18000000; // add 5 hours in ms / добавить 5 часов в мс --> (GMT+5) | |
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm dd MMMM, yyyy", new Locale("ru")); // new pattern/новый шаблон new Russian locale/новая русская локализация | |
dateString = formatter.format(new Date(newDate)); | |
} catch(ParseException e) { | |
e.printStackTrace(); | |
} | |
dateString // result/результат | |
// output/вывод: 16:52 23 Июнь, 2018 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment