Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package date_time_and_other;
- import java.time.*;
- import java.time.format.DateTimeFormatter;
- import java.time.format.FormatStyle;
- import java.time.temporal.ChronoUnit;
- import java.util.*;
- import java.util.Scanner;
- import java.lang.String;
- public class Date_Time {
- public static void main(String[] args) {
- try {
- System.out.println("Выберете язык: \n en - EN\n eu - RU \n uz - UZ\n");
- Scanner in = new Scanner(System.in);
- String num = in.next();
- // Русский
- Locale.setDefault(new Locale(num, num));
- System.out.println("Вы выбрали " + Locale.getDefault());
- ResourceBundle myBundle = ResourceBundle.getBundle("MyLabels");
- //Узбекский
- //Locale.setDefault(new Locale("uz", "UZ"));
- //System.out.println("Siz o'zbek tilini tanladingiz: " + Locale.getDefault());
- //myBundle = ResourceBundle.getBundle("MyLabels_uz_UZ");
- // Английский
- //Locale.setDefault(new Locale("en", "EN"));
- //System.out.println("You have chosen English: " + Locale.getDefault());
- //yBundle = ResourceBundle.getBundle("MyLabels_en_EN");
- long milSecondFromEpoch = Instant.ofEpochMilli(0L).until(Instant.now(), ChronoUnit.MILLIS);
- int daysFromEpoch = (int) (milSecondFromEpoch / 86400000);
- int yearsFromEpoch = daysFromEpoch / 365;
- Instant UTStart = Instant.ofEpochMilli(milSecondFromEpoch - milSecondFromEpoch);
- ZonedDateTime ZUTStart = UTStart.atZone(ZoneId.of("Asia/Tashkent"));
- System.out.println(ZonedDateTime.now().format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL)) + " " + myBundle.getString("date"));//" - Текущая дата и время.");
- System.out.print(milSecondFromEpoch + " " + myBundle.getString("milisec") + " ");//" - милисекунд или ");
- System.out.print(daysFromEpoch + " " + myBundle.getString("days") + " "); //+ " - дней, или ");
- System.out.println(yearsFromEpoch + " " + myBundle.getString("years") /*" - лет, прошло с "*/ + " " + (ZUTStart.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL))) + " " + myBundle.getString("moment"));//", момента запуска Unix time");
- Scanner ini = new Scanner(System.in);
- System.out.println(myBundle.getString("insert_the_number"));//"Введите число:");
- long nums = ini.nextLong();
- Instant dt = Instant.ofEpochMilli(nums);
- ZonedDateTime zdt = dt.atZone(ZoneId.of("Asia/Tashkent"));
- System.out.println(zdt.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL)));
- long daysBetween = ChronoUnit.DAYS.between(UTStart, dt);
- //double weeksBetween = daysBetween/7;
- System.out.println(daysBetween + " " + myBundle.getString("since"));//" день с момента запуска Unix time.");
- //System.out.println(weeksBetween + " недель про...");
- System.out.println(myBundle.getString("bye"));
- } catch (MissingResourceException exc) {
- System.out.println("Вы ввели недопустимое значение.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement