How do I fix an error? When I send a message, the date appears correctly, but when I receive a message, the date appears incorrectly. For example, 5 p.m., the date appears at 8 p.m. Here is a three-hour difference.
AdapterChat:
Код: Выделить всё
Calendar cal = Calendar.getInstance(Locale.US);
cal.setTimeInMillis(Long.parseLong(timeStamp));
String dateTime = DateFormat.format("dd/MM/yyyy hh:mm aa", cal).toString();
Код: Выделить всё
String timestamp = String.valueOf(System.currentTimeMillis());
AdapterChat:
Код: Выделить всё
Calendar cal = Calendar.getInstance(Locale.getDefault());
cal.setTimeInMillis(Long.parseLong(timeStamp));
String dateTime = DateFormat.format("dd/MM/yyyy hh:mm aa", cal).toString();
Код: Выделить всё
String timestamp = String.valueOf(System.currentTimeMillis());
Источник: https://stackoverflow.com/questions/781 ... l-tostring
Мобильная версия