Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Calendar calendar = Calendar.getInstance();
- int year = calendar.get(Calendar.YEAR);
- int month = calendar.get(Calendar.MONTH);
- calendar.set(year, month, 1);
- //Первый месяц в Date считается 0 (Январь), последний - 11(Декабрь)
- final int firstMonth = 0;
- final int firstDay = 1;
- //Давайте получим 01.01.ТЕКУЩИЙ_ГОД в миллисекундах.
- //Для этого создадим объект Date с датой 01.01.ТЕКУЩИЙ_ГОД
- Date current_year = new Date(Calendar.getInstance().getTime().getYear(), firstMonth, firstDay);
- //получим количество секунд на 01.01.ТЕКУЩИЙ_ГОД 00:00:00 UTC
- long current_year_in_milliseconds = current_year.getTime();
- public static long getCurrentYearTimeInMilliseconds(){
- //код
- }
Add Comment
Please, Sign In to add comment