diff options
author | Elliott Hughes <enh@google.com> | 2013-03-19 09:30:51 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-03-19 09:30:51 -0700 |
commit | c3e513e51caad56a30186d9e20a814dcc53e72ef (patch) | |
tree | d1f492bfeee6d79ef0dfe6bbf4c201e521e8c514 /core/java/android/text/format | |
parent | 11f36b80d494a6c9df235e32b61820187eb8f22e (diff) | |
parent | c5c6d4167b66c79652c5208a2dfe091a8c735e6d (diff) | |
download | frameworks_base-c3e513e51caad56a30186d9e20a814dcc53e72ef.zip frameworks_base-c3e513e51caad56a30186d9e20a814dcc53e72ef.tar.gz frameworks_base-c3e513e51caad56a30186d9e20a814dcc53e72ef.tar.bz2 |
am c5c6d416: am 6317315e: Merge "Deliberately break DateFormat.format\'s formatting of \'k\' for compatibility."
* commit 'c5c6d4167b66c79652c5208a2dfe091a8c735e6d':
Deliberately break DateFormat.format's formatting of 'k' for compatibility.
Diffstat (limited to 'core/java/android/text/format')
-rw-r--r-- | core/java/android/text/format/DateFormat.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java index be4663d..9e7c93c 100644 --- a/core/java/android/text/format/DateFormat.java +++ b/core/java/android/text/format/DateFormat.java @@ -43,11 +43,17 @@ import libcore.icu.LocaleData; * for both formatting and parsing dates. For the canonical documentation * of format strings, see {@link java.text.SimpleDateFormat}. * - * <p>The format methods in this class implement a subset of Unicode + * <p>The {@code format} methods in this class implement a subset of Unicode * <a href="http://www.unicode.org/reports/tr35/#Date_Format_Patterns">UTS #35</a> patterns. - * The subset supported by this class includes the following format characters: - * {@code acdEHhLKkLMmsyz}. See {@link java.text.SimpleDateFormat} for more documentation - * about patterns, or if you need a more compete implementation. + * The subset currently supported by this class includes the following format characters: + * {@code acdEHhLKkLMmsyz}. Up to API level 17, only {@code adEhkMmszy} were supported. + * Note that this class incorrectly implements {@code k} as if it were {@code H} for backwards + * compatibility. + * + * <p>See {@link java.text.SimpleDateFormat} for more documentation + * about patterns, or if you need a more complete or correct implementation. + * Note that the non-{@code format} methods in this class are implemented by + * {@code SimpleDateFormat}. */ public class DateFormat { /** @deprecated Use a literal {@code '} instead. */ @@ -74,7 +80,11 @@ public class DateFormat { @Deprecated public static final char HOUR = 'h'; - /** @deprecated Use a literal {@code 'k'} instead. */ + /** + * @deprecated Use a literal {@code 'H'} (for compatibility with {@link SimpleDateFormat} + * and Unicode) or {@code 'k'} (for compatibility with Android releases up to and including + * Jelly Bean MR-1) instead. Note that the two are incompatible. + */ @Deprecated public static final char HOUR_OF_DAY = 'k'; @@ -451,10 +461,13 @@ public class DateFormat { } break; case 'H': // hour in day (0-23) - case 'k': // hour in day (1-24) + case 'k': // hour in day (1-24) [but see note below] { int hour = inDate.get(Calendar.HOUR_OF_DAY); - if (c == 'k' && hour == 0) { + // Historically on Android 'k' was interpreted as 'H', which wasn't + // implemented, so pretty much all callers that want to format 24-hour + // times are abusing 'k'. http://b/8359981. + if (false && c == 'k' && hour == 0) { hour = 24; } replacement = zeroPad(hour, count); |