History log of /frameworks/base/core/java/android/text/format/DateUtils.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
f9818d33f94686ee9c80697ec79ef557a7b77176 16-Aug-2013 Elliott Hughes <enh@google.com> Fix NPE in DateFormat.is24HourFormat.

In some cases, we end up being called by code that doesn't have a valid
Context. It got away with this historically because it wasn't formatting
times (just dates), so it never went down a path that tried to query the
user's 12/24-hour preference. This patch just ensures that we don't try
to get the preference unless we actually need it.

Bug: 10339015

(cherry picked from commit 8d8ef00c8276200f108433922761401817fd9a50)

Change-Id: If074a67fa52943c0ec7bb5c5bbe5a11f54fb1f97
/frameworks/base/core/java/android/text/format/DateUtils.java
12285f3d9f756226c13ef93054b87e0d487e1409 15-Aug-2013 Elliott Hughes <enh@google.com> DateUtils should use the user's 12/24-hour preference, not the locale's.

Bug: 10312832

(cherry picked from commit f0b79aeed36f0839e4effaa36893b7ca71292563)

Change-Id: I0d78725d47009553f9003ccfba06f70f178a6ec1
/frameworks/base/core/java/android/text/format/DateUtils.java
6139e64cd6f86c4e3983de976cb0aa976b0d313c 24-Jul-2013 Elliott Hughes <enh@google.com> Switch DateUtils.formatDateRange over to an icu4c-based implementation.

Bug: 7289514
Change-Id: Ia382f49aa23737bde91b7891d95545da084ec57c
/frameworks/base/core/java/android/text/format/DateUtils.java
fbf37c79bdedbdd7b82ad7d5862dd82e3c068590 26-Mar-2013 Elliott Hughes <enh@google.com> Remove dead DateUtils code that was never in an API level.

Also rewrite @deprecated comments to use an initial capital so they
look right in the generated documentation.

Also improve formatIpAddress documentation.

Change-Id: I317ebe411ef76e16a4535318ce73e00b63af38da
/frameworks/base/core/java/android/text/format/DateUtils.java
9a6fa1d637ddd1be0978d6889270bcd7dad4e46a 19-Mar-2013 Elliott Hughes <enh@google.com> Remove dead code from DateUtils.

This stuff is @hide, @deprecated, unused, and was never in any API level.

Change-Id: I87d132d77d7296a2de8527e05c2def362cab1c37
/frameworks/base/core/java/android/text/format/DateUtils.java
9a2ada418b0a53cb10e009398116ff8cd914d71e 28-Feb-2013 Sungmin Choi <sungmin.choi@lge.com> use Calendar in DateUtils format method

The DatePickerDialog is using DateUtils to format the dialog's title
and the DateUtils class does not work with dates outside to the
specified range.
For example, if user selects 2038-03-07, DatePickerDialog shows
1902-01-30 on Title.
The reason for the DateUtils class not being able to format dates
outside the range of 1902 and 2036 is because internally it is using
the Time class which does not support such dates.
To fix it, use Calendar class in DataUilts format method.

Steps to reproduce:
1. Settings -> Date & time
2. uncheck Automatic date & time
3. Set Date
4. choose any date before 1902 or after 2037
5. update wrong date on Title

Bug: https://code.google.com/p/android/issues/detail?id=13050
Change-Id: I003266765751b5c340426af84daef271f39f771e
/frameworks/base/core/java/android/text/format/DateUtils.java
8326b9a429b63b680aa9af116c670ce674744d80 09-Mar-2013 Elliott Hughes <enh@google.com> Improve DateFormat.format.

Add support for the 'c' format character, required in many non-English locales.
Reimplement 'c' and 'E', and 'L' and 'M', so they correctly interpret 5-count
pattern characters.

Replace the old incorrect class documentation with a pointer to the
well-maintained libcore equivalent and the Unicode UTS to which these two
implementations are supposed to conform.

Deprecate the useless constants for pattern characters. No one sane is going
to write MONTH + MONTH + MONTH + MONTH instead of "MMMM".

Correct the documentation for getLongDateFormat and getMediumDateFormat.

Also fix DateUtils.getStandaloneMonthString for LENGTH_SHORTEST.

Tests are in https://android-review.googlesource.com/53291.

Change-Id: I4dda8b18070f05ccdc11c1f0a9381a9d233db4e8
/frameworks/base/core/java/android/text/format/DateUtils.java
5acc6e521494f1ea21c793d0b56667dae107a1be 08-Mar-2013 Elliott Hughes <enh@google.com> Use getRelativeDayString in getRelativeTimeSpanString.

The bug we're fixing here is that languages that don't
distinguish the "one" case grammatically (such as Japanese)
would say the equivalent of "In 1 day" rather than "Tomorrow"
because of the misuse of getQuantityString.

This has the side-effect of switching us over to the CLDR
strings for relative day names, which have consistent capitalization;
the Android donottranslate-cldr.xml strings varied even within
a language, so although this is a change, it seems like a step
in the right direction.

In a future change, we should actually push all relative
day formatting down into icu4c.

Bug: 7098707
Change-Id: Ia2f9af3d18c441d6093dd5da7956a3d0130e5b06
/frameworks/base/core/java/android/text/format/DateUtils.java
6647f1bd2b3a615cf02111aab21eecdd76ce7c09 15-Dec-2012 Elliott Hughes <enh@google.com> am c749261f: Merge "Fix DateUtils.formatElapsedTime."

* commit 'c749261fea1010dfa2d1337bd210c81d13052540':
Fix DateUtils.formatElapsedTime.
2eda18485cefc5dbc946d7eb32486a7bd67bf8af 14-Dec-2012 Elliott Hughes <enh@google.com> Fix DateUtils.formatElapsedTime.

More reuse of StringBuilders, less broken home-grown formatting code.

Long-term, we should hand this over to icu4c, but they're not ready yet.

Bug: http://code.google.com/p/android/issues/detail?id=41401
Bug: 7736688
Change-Id: Ib3c1e1aad05827df646aa18645cce19dffb7551f
/frameworks/base/core/java/android/text/format/DateUtils.java
53f6e8a9b95a1fe5229295ade4989339d577de08 14-Nov-2012 Jeff Sharkey <jsharkey@android.com> Utility to format human-friendly durations.

Bug: 6777872
Change-Id: Ie7ebcb456306f4f88b4707030dd7beda3fc90368
/frameworks/base/core/java/android/text/format/DateUtils.java
9ccf13cd6b7c840105fbcd6b2a8bd61d4e634653 19-Sep-2012 Elliott Hughes <enh@google.com> Fix formatDateRange month names for Farsi.

This removes the LLLs seen in Calendar and Settings, for example.

Bug: 6811327
Change-Id: I87c2ab9ee8d897171ce7ca4fe06cfa8b11d36536
/frameworks/base/core/java/android/text/format/DateUtils.java
315a7c0335fb54beced23b1703c10563ce02ee82 18-Sep-2012 Roozbeh Pournader <roozbeh@google.com> Use proper digits in formatElapsedTime and format3339

Use getZeroDigit() instead of a hard-coded '0' for formatting times using
formatElapsedTime, so locales with different digits like Arabic and Persian
could display the elapsed time properly. This is visible in Settings' list
of running apps.

Also changed android.text.format.Time's format3339 method to always use ASCII
digits, irrespective of the locale.

Change-Id: I731c96c21b3712ec347d9526e4ec3fe884dec276
/frameworks/base/core/java/android/text/format/DateUtils.java
c3ff72f5bd5896ad2584e0cc0582cbd2ad8191f2 15-Aug-2012 Elliott Hughes <enh@google.com> Use icu4c for CLDR "yesterday", "today", and "tomorrow" strings.

(cherry-pick of 47a0539ecaf7d7a15008704bd89f748aebf85d47.)

Conflicts:

core/res/res/values/public.xml

Bug: 6811501
Change-Id: Ifb2e030a9fda85a7f664feac812b63e67780e68f
/frameworks/base/core/java/android/text/format/DateUtils.java
08153ee01e6aa67061f628bc3fed66c6400dfd1c 07-Aug-2012 Elliott Hughes <enh@google.com> Switch DateUtils and Time over to using the CLDR for all week and month names.

(cherry-pick of 99c406e42ba154584070ca7ec100e8be7ff8a800.)

Conflicts:

core/res/res/values-fa/donottranslate-cldr.xml
core/res/res/values/public.xml

Bug: 6811501
Change-Id: I2ad9608ae34804e02c6b0271197e96611df12b0a
/frameworks/base/core/java/android/text/format/DateUtils.java
4af85345e798c37ab026e93a1ae250d8bca4fc40 26-Jul-2012 Elliott Hughes <enh@google.com> Use ICU's CLDR data for "AM" and "PM" strings.

This brings DateUtils and Time in sync with bionic, icu, WebKit,
DateFormatSymbols, Formatter, and SimpleDateFormat. And specifically
means that DateUtils now knows how to say "AM" and "PM" in Japanese.

Bug: 6719054

(cherry-pick of b12b61a88a029730b1f2b006ff914c9c719f3942.)

Conflicts:

core/res/res/values/public.xml

Change-Id: Ic1a811621a0ec338abd77458ac2046577f87c1e4
/frameworks/base/core/java/android/text/format/DateUtils.java
d3c01012d8d329e541214e8207272ab5cc9ca004 29-Aug-2012 Elliott Hughes <enh@google.com> Deprecate those parts of DateUtils the documentation says not to use.

Applications using these fields and methods are just asking for i18n bugs.

Also @deprecate two int[]s that were never meant to be public.

Change-Id: I29b3a1c0c663fe344d2567df6ed3bb537270b3b7
/frameworks/base/core/java/android/text/format/DateUtils.java
ca3363775e03e0f90bdf111d3e5c54b3ab16df57 27-Aug-2012 Steve Pomeroy <steve@staticfree.info> Fixes relative time formatting issue for dates in future

All variations of getRelativeTimeSpanString() now properly handle dates
that are in the future. Prior, the version used by
getRelativeDateTimeString() would occasionally show the time instead of
a date when the future date was the same weekday as the current weekday.
This resulted in the time output being duplicated, eg.: "11:23, 11:23"

Change-Id: If20972a6942cce792fa233437f94dedfb71379f3
Signed-off-by: Steve Pomeroy <steve@staticfree.info>
/frameworks/base/core/java/android/text/format/DateUtils.java
4cf8a3914aa365fefc6c231c48075ecc5a096a65 23-Nov-2011 Owen Lin <owenlin@google.com> am 85c38af1: am 8bb56180: Merge "Fix 5654631. It forgot to consider the year in formatDateRange." into ics-mr1

* commit '85c38af1d47e288775052cd188e3f014fa40e8a2':
Fix 5654631. It forgot to consider the year in formatDateRange.
b193e35ed131769e6c98b2752635065489198aeb 22-Nov-2011 Owen Lin <owenlin@google.com> Fix 5654631. It forgot to consider the year in formatDateRange.

Change-Id: I494e3ecc7a2e7c418ed61930ffd7311338c11783
fix: 5654631
/frameworks/base/core/java/android/text/format/DateUtils.java
99a64f4b1d2519b71558fdc62721686445865b60 11-Nov-2011 Jesse Wilson <jessewilson@google.com> Document our potentially suprising behavior on date ranges ending at midnight.

Bug: http://code.google.com/p/android/issues/detail?id=18512
Change-Id: I968ca1cfcef79273ee856624a640d56b038b96be
/frameworks/base/core/java/android/text/format/DateUtils.java
25d8b05fb77e8ee755aacd27c1c2d3b237537b7a 22-Feb-2011 Jozef BABJAK <jozef.babjak@gmail.com> Ensuring thread-safe usage of DateFormat.

DateFormat is inherently unsafe for multithreaded use. This patch adds
proper synchronization. The 'sLock' is re-used. To avoid two consecutive
lockings, locked version of initFormatStrings() method is created and
used where appropriate, i.e. in original method AND in added synchronized
block.

Change-Id: Id3c34613623e743e703aadb2342aa788679dda8a
/frameworks/base/core/java/android/text/format/DateUtils.java
c4f628a1ba359926cf53ed7652d9abba6ea29123 08-Sep-2010 Erik <roboerik@android.com> am c0b4f6d3: Merge "Adds a time zone parameter to formatDateRange" into gingerbread

Merge commit 'c0b4f6d30d962d75125628317b5f5ea622531dfe' into gingerbread-plus-aosp

* commit 'c0b4f6d30d962d75125628317b5f5ea622531dfe':
Adds a time zone parameter to formatDateRange
577ec9eb3a661de96a2cbe9ec918eda082fb7659 02-Sep-2010 Erik <roboerik@android.com> Adds a time zone parameter to formatDateRange

For a critical feature request in Calendar we need the ability
to format a date range in a time zone other than the local tz.
This adds a new method signature to formatDateRange to allow for
a tz to be specified and maintains the old behavior if the parameter
is not used. Also deprecates the FORMAT_UTC flag.

Change-Id: I16b3e939760ec86c954b51a318d01b7bbf86acc9
/frameworks/base/core/java/android/text/format/DateUtils.java
f1f33c4eb2ded794c74285d8a036073ae5419f25 18-Jun-2010 The Android Open Source Project <initial-contribution@android.com> merge from open-source master

Change-Id: If7ae0c5629d1b3c540cacfa517425c2e6b5822d1
6a84af0949b341593b4b25ed9bb365bd60ff1254 29-Mar-2010 David Sobreira Marques <dpsmarques@gmail.com> Fixing counting the number of days in call log screen.

Counting the number of days in call log screen when a
call was made/received within a week is not correct.

Issue 3132: Call Log Reporting Wrong

Change-Id: I99c3cb40267b4b5938ccc4225993b7aac7e2d018
Signed-off-by: David Sobreira Marques <dpsmarques@gmail.com>
/frameworks/base/core/java/android/text/format/DateUtils.java
a53bbe4033f1e9fc4c371d51ba1ef58588f867eb 01-Mar-2010 Ken Shirriff <kens@google.com> Remove DateException and obsolete DateUtils functions.

These functions are deprecated and no longer used.
/frameworks/base/core/java/android/text/format/DateUtils.java
becfc9de9e18ef216c2b537cd2829f1d2d55404f 30-Jun-2009 Michael Chan <mchan@android.com> Added a Formatter parameter to DateUtils.formatDateRange

DateUtils.formatDateRange is using String.format which isn't efficient for
formatting large number of strings. I have added the Formatter parameter which
allows the caller to reuse the formatter of subsequent calls for faster
performance.
/frameworks/base/core/java/android/text/format/DateUtils.java
5669ce59aad19f17e1e89913e7483fb93b8aa0cf 18-Jun-2009 Eric Fischer <enf@google.com> Work around the Czech lack of abbreviated month names.

Make the date formats that want abbreviated month names use either
the full name or a numeric format.
/frameworks/base/core/java/android/text/format/DateUtils.java
84c863d9af1270a2ccd2ccd2b8c1a753826dfe6d 10-Jun-2009 Eric Fischer <enf@google.com> Fix some 12- vs 24-hour problems in the FormatDateRange strings.

Use a resource instead of a hardcoded string for the 24-hour format
since it is not exactly the same in every locale.

Make sure the 12-hour format is actually for a 12-hour clock, even in
locales where this is not a normal thing to do. In the cap_ampm version,
do not have it try to capitalize "am" and "pm" if these are non-ASCII
strings, since strftime() doesn't know about Unicode and will mess it up.

Add a comment so that people don't think the YEAR_IN_MILLIS constant is
actually the length of any real year.
/frameworks/base/core/java/android/text/format/DateUtils.java
5bd644caf73e76750feef1a82b8817d32f5367fc 13-May-2009 Eric Fischer <enf@google.com> Start using CLDR for some date-and-time strings and formats.

Use java.text.DateFormat where possible, since that is already using
the CLDR data for the things it supports. Remove an unused date format
object from DatePickerDialog.

Add a new method for getting the standalone month names from applications,
although @hidden for now because it is an API change.

Pass the standalone month names down to native code in Time so that
tztime's strftime() can use them.

And then the bulk of the change: replace all the names for the months
and the days of the week, and AM and PM, and yesterday, today, and tomorrow,
with strings from CLDR. And replace several of the date format strings
with ones derived from CLDR, but reformatted to use strftime() style
instead of SimpleDateFormat style.

All these resource changes go into new donottranslate-cldr.xml files
and are removed from strings.xml so that they aren't part of the
normal translation process and the translators don't have to bother
with them (and risk messing them up).
/frameworks/base/core/java/android/text/format/DateUtils.java
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/text/format/DateUtils.java
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/text/format/DateUtils.java
076357b8567458d4b6dfdcf839ef751634cd2bfb 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@132589
/frameworks/base/core/java/android/text/format/DateUtils.java
3dec7d563a2f3e1eb967ce2054a00b6620e3558c 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@137055
/frameworks/base/core/java/android/text/format/DateUtils.java
b798689749c64baba81f02e10cf2157c747d6b46 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
/frameworks/base/core/java/android/text/format/DateUtils.java
f013e1afd1e68af5e3b868c26a653bbfb39538f8 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
/frameworks/base/core/java/android/text/format/DateUtils.java