Guest User

Untitled

a guest
Mar 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. private static String getDayName(Context context, long dateInMillis) {
  2. ZoneId zone = ZoneId.systemDefault();
  3. LocalDate providedDate = Instant.ofEpochMilli(dateInMillis)
  4. .atZone(zone)
  5. .toLocalDate();
  6. LocalDate today = LocalDate.now(zone);
  7.  
  8. int daysAfterToday = (int) ChronoUnit.DAYS.between(today, providedDate);
  9.  
  10. switch (daysAfterToday) {
  11. case 0:
  12. return context.getString(R.string.today);
  13. case 1:
  14. return context.getString(R.string.tomorrow );
  15.  
  16. default:
  17. return providedDate.getDayOfWeek()
  18. .getDisplayName(TextStyle.FULL,
  19. Locale.getDefault(Locale.Category.FORMAT));
  20. }
  21. }
  22.  
  23. ZoneId zone = ZoneId.of("America/Cordoba");
Add Comment
Please, Sign In to add comment