Commit 7bcff480 authored by Tao Bao's avatar Tao Bao
Browse files

Use ICU for relative time formatting

Rewrite the DateUtils' relative time formatting APIs
(getRelativeTimeSpanString, getRelativeDateTimeString) to use ICU ones.
Two APIs that take withPreposition parameter are not changed. Because
(a) ICU doesn't provide functionality to format preposition; (b) They
are not really computing relative time but instead calling
formatDateRange() to get the absolute time/date string.

Benchmark results on aosp_hammerhead-userdebug:

before:
                                     benchmark    us linear runtime
           DateUtils_getRelativeDateTimeString 127.1 ==========================
    DateUtils_getRelativeDateTimeString_ABBREV 145.0 ==============================
           DateUtils_getRelativeTimeSpanString  28.0 =====
    DateUtils_getRelativeTimeSpanString_ABBREV  27.9 =====

now:
                                                     benchmark    us linear runtime
           RelativeDateTimeFormatter_getRelativeDateTimeString 119.2 ==========================
    RelativeDateTimeFormatter_getRelativeDateTimeString_ABBREV 133.8 ==============================
           RelativeDateTimeFormatter_getRelativeTimeSpanString  24.6 =====
    RelativeDateTimeFormatter_getRelativeTimeSpanString_ABBREV  24.7 =====

Bug: 19146457
Bug: 5252772
Change-Id: Ief74608354964a17e42191d7b1a58964f3a9acfd
parent a9c24ad8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment