0
현재 출력을 얻으려면 DateUtils.getRelativeTimeSpanString
을 사용하고 있습니다.DateUtils.getRelativeTimeSpanString 적절한 결과가 없습니다.
8 minutes ago
8 hours ago
대신 반환합니다. 내 코드는 다음과 post
In 4 hr
In 5 hr
정확히 것은 여기에 내 코드
long postTime = getDateInMillis(pubDate);
CharSequence time = DateUtils.getRelativeTimeSpanString(System.currentTimeMillis(),postTime,DateUtils.MINUTE_IN_MILLIS,DateUtils.FORMAT_ABBREV_RELATIVE);
내 getDateInMillis 방법
public static long getDateInMillis(String srcDate) {
SimpleDateFormat formatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z",Locale.getDefault());
long dateInMillis = 0;
try {
Date date = formatter.parse(srcDate);
dateInMillis = date.getTime();
return dateInMillis;
}
catch (java.text.ParseException e) {
e.printStackTrace();
}
return 0;
}
날 내가 원하는 올바른 형식을 받고 도와주세요입니다. 감사.