use of org.threeten.bp.format.DateTimeFormatter in project wire-android by wireapp.
the class ZTimeFormatter method getSingleMessageTime.
private static String getSingleMessageTime(Context context, Date date, boolean defaultLocale) {
boolean is24HourFormat = DateFormat.is24HourFormat(context);
Resources resources = defaultLocale ? getEnglishResources(context) : context.getResources();
final String pattern = is24HourFormat ? resources.getString(R.string.timestamp_pattern__24h_format) : resources.getString(R.string.timestamp_pattern__12h_format);
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
return formatter.format(DateConvertUtils.asLocalDateTime(date).atZone(ZoneId.systemDefault()));
} catch (Exception e) {
ExceptionHandler.saveException(e, Thread.currentThread(), new CrashManagerListener() {
@Override
public String getDescription() {
return pattern;
}
});
if (!defaultLocale) {
return getSingleMessageTime(context, date, true);
} else {
return "";
}
}
}
Aggregations