Skip to content

Commit 7f269e4

Browse files
committed
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. (cherry-pick of d3c0101.) Change-Id: I9fd131108ad82bacb9434ffbf40eddfde3459862
1 parent 0b62fa2 commit 7f269e4

File tree

2 files changed

+50
-19
lines changed

2 files changed

+50
-19
lines changed

api/current.txt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22205,34 +22205,34 @@ package android.text.format {
2220522205
method public static java.lang.String formatElapsedTime(long);
2220622206
method public static java.lang.String formatElapsedTime(java.lang.StringBuilder, long);
2220722207
method public static final java.lang.CharSequence formatSameDayTime(long, long, int, int);
22208-
method public static java.lang.String getAMPMString(int);
22209-
method public static java.lang.String getDayOfWeekString(int, int);
22210-
method public static java.lang.String getMonthString(int, int);
22208+
method public static deprecated java.lang.String getAMPMString(int);
22209+
method public static deprecated java.lang.String getDayOfWeekString(int, int);
22210+
method public static deprecated java.lang.String getMonthString(int, int);
2221122211
method public static java.lang.CharSequence getRelativeDateTimeString(android.content.Context, long, long, long, int);
2221222212
method public static java.lang.CharSequence getRelativeTimeSpanString(long);
2221322213
method public static java.lang.CharSequence getRelativeTimeSpanString(long, long, long);
2221422214
method public static java.lang.CharSequence getRelativeTimeSpanString(long, long, long, int);
2221522215
method public static java.lang.CharSequence getRelativeTimeSpanString(android.content.Context, long, boolean);
2221622216
method public static java.lang.CharSequence getRelativeTimeSpanString(android.content.Context, long);
2221722217
method public static boolean isToday(long);
22218-
field public static final java.lang.String ABBREV_MONTH_FORMAT = "%b";
22218+
field public static final deprecated java.lang.String ABBREV_MONTH_FORMAT = "%b";
2221922219
field public static final java.lang.String ABBREV_WEEKDAY_FORMAT = "%a";
2222022220
field public static final long DAY_IN_MILLIS = 86400000L; // 0x5265c00L
22221-
field public static final int FORMAT_12HOUR = 64; // 0x40
22222-
field public static final int FORMAT_24HOUR = 128; // 0x80
22221+
field public static final deprecated int FORMAT_12HOUR = 64; // 0x40
22222+
field public static final deprecated int FORMAT_24HOUR = 128; // 0x80
2222322223
field public static final int FORMAT_ABBREV_ALL = 524288; // 0x80000
2222422224
field public static final int FORMAT_ABBREV_MONTH = 65536; // 0x10000
2222522225
field public static final int FORMAT_ABBREV_RELATIVE = 262144; // 0x40000
2222622226
field public static final int FORMAT_ABBREV_TIME = 16384; // 0x4000
2222722227
field public static final int FORMAT_ABBREV_WEEKDAY = 32768; // 0x8000
22228-
field public static final int FORMAT_CAP_AMPM = 256; // 0x100
22229-
field public static final int FORMAT_CAP_MIDNIGHT = 4096; // 0x1000
22230-
field public static final int FORMAT_CAP_NOON = 1024; // 0x400
22231-
field public static final int FORMAT_CAP_NOON_MIDNIGHT = 5120; // 0x1400
22228+
field public static final deprecated int FORMAT_CAP_AMPM = 256; // 0x100
22229+
field public static final deprecated int FORMAT_CAP_MIDNIGHT = 4096; // 0x1000
22230+
field public static final deprecated int FORMAT_CAP_NOON = 1024; // 0x400
22231+
field public static final deprecated int FORMAT_CAP_NOON_MIDNIGHT = 5120; // 0x1400
2223222232
field public static final int FORMAT_NO_MIDNIGHT = 2048; // 0x800
2223322233
field public static final int FORMAT_NO_MONTH_DAY = 32; // 0x20
2223422234
field public static final int FORMAT_NO_NOON = 512; // 0x200
22235-
field public static final int FORMAT_NO_NOON_MIDNIGHT = 2560; // 0xa00
22235+
field public static final deprecated int FORMAT_NO_NOON_MIDNIGHT = 2560; // 0xa00
2223622236
field public static final int FORMAT_NO_YEAR = 8; // 0x8
2223722237
field public static final int FORMAT_NUMERIC_DATE = 131072; // 0x20000
2223822238
field public static final int FORMAT_SHOW_DATE = 16; // 0x10
@@ -22241,12 +22241,12 @@ package android.text.format {
2224122241
field public static final int FORMAT_SHOW_YEAR = 4; // 0x4
2224222242
field public static final deprecated int FORMAT_UTC = 8192; // 0x2000
2224322243
field public static final long HOUR_IN_MILLIS = 3600000L; // 0x36ee80L
22244-
field public static final java.lang.String HOUR_MINUTE_24 = "%H:%M";
22245-
field public static final int LENGTH_LONG = 10; // 0xa
22246-
field public static final int LENGTH_MEDIUM = 20; // 0x14
22247-
field public static final int LENGTH_SHORT = 30; // 0x1e
22248-
field public static final int LENGTH_SHORTER = 40; // 0x28
22249-
field public static final int LENGTH_SHORTEST = 50; // 0x32
22244+
field public static final deprecated java.lang.String HOUR_MINUTE_24 = "%H:%M";
22245+
field public static final deprecated int LENGTH_LONG = 10; // 0xa
22246+
field public static final deprecated int LENGTH_MEDIUM = 20; // 0x14
22247+
field public static final deprecated int LENGTH_SHORT = 30; // 0x1e
22248+
field public static final deprecated int LENGTH_SHORTER = 40; // 0x28
22249+
field public static final deprecated int LENGTH_SHORTEST = 50; // 0x32
2225022250
field public static final long MINUTE_IN_MILLIS = 60000L; // 0xea60L
2225122251
field public static final java.lang.String MONTH_DAY_FORMAT = "%-d";
2225222252
field public static final java.lang.String MONTH_FORMAT = "%B";
@@ -22257,8 +22257,8 @@ package android.text.format {
2225722257
field public static final java.lang.String YEAR_FORMAT = "%Y";
2225822258
field public static final java.lang.String YEAR_FORMAT_TWO_DIGITS = "%g";
2225922259
field public static final long YEAR_IN_MILLIS = 31449600000L; // 0x7528ad000L
22260-
field public static final int[] sameMonthTable;
22261-
field public static final int[] sameYearTable;
22260+
field public static final deprecated int[] sameMonthTable;
22261+
field public static final deprecated int[] sameYearTable;
2226222262
}
2226322263

2226422264
public final class Formatter {

core/java/android/text/format/DateUtils.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,17 @@ public class DateUtils
161161
public static final int FORMAT_NO_YEAR = 0x00008;
162162
public static final int FORMAT_SHOW_DATE = 0x00010;
163163
public static final int FORMAT_NO_MONTH_DAY = 0x00020;
164+
@Deprecated
164165
public static final int FORMAT_12HOUR = 0x00040;
166+
@Deprecated
165167
public static final int FORMAT_24HOUR = 0x00080;
168+
@Deprecated
166169
public static final int FORMAT_CAP_AMPM = 0x00100;
167170
public static final int FORMAT_NO_NOON = 0x00200;
171+
@Deprecated
168172
public static final int FORMAT_CAP_NOON = 0x00400;
169173
public static final int FORMAT_NO_MIDNIGHT = 0x00800;
174+
@Deprecated
170175
public static final int FORMAT_CAP_MIDNIGHT = 0x01000;
171176
/**
172177
* @deprecated Use
@@ -181,19 +186,25 @@ public class DateUtils
181186
public static final int FORMAT_NUMERIC_DATE = 0x20000;
182187
public static final int FORMAT_ABBREV_RELATIVE = 0x40000;
183188
public static final int FORMAT_ABBREV_ALL = 0x80000;
189+
@Deprecated
184190
public static final int FORMAT_CAP_NOON_MIDNIGHT = (FORMAT_CAP_NOON | FORMAT_CAP_MIDNIGHT);
191+
@Deprecated
185192
public static final int FORMAT_NO_NOON_MIDNIGHT = (FORMAT_NO_NOON | FORMAT_NO_MIDNIGHT);
186193

187194
// Date and time format strings that are constant and don't need to be
188195
// translated.
189196
/**
190197
* This is not actually the preferred 24-hour date format in all locales.
198+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
191199
*/
200+
@Deprecated
192201
public static final String HOUR_MINUTE_24 = "%H:%M";
193202
public static final String MONTH_FORMAT = "%B";
194203
/**
195204
* This is not actually a useful month name in all locales.
205+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
196206
*/
207+
@Deprecated
197208
public static final String ABBREV_MONTH_FORMAT = "%b";
198209
public static final String NUMERIC_MONTH_FORMAT = "%m";
199210
public static final String MONTH_DAY_FORMAT = "%-d";
@@ -207,6 +218,7 @@ public class DateUtils
207218
// The index is constructed from a bit-wise OR of the boolean values:
208219
// {showTime, showYear, showWeekDay}. For example, if showYear and
209220
// showWeekDay are both true, then the index would be 3.
221+
/** @deprecated do not use. */
210222
public static final int sameYearTable[] = {
211223
com.android.internal.R.string.same_year_md1_md2,
212224
com.android.internal.R.string.same_year_wday1_md1_wday2_md2,
@@ -233,6 +245,7 @@ public class DateUtils
233245
// The index is constructed from a bit-wise OR of the boolean values:
234246
// {showTime, showYear, showWeekDay}. For example, if showYear and
235247
// showWeekDay are both true, then the index would be 3.
248+
/** @deprecated do not use. */
236249
public static final int sameMonthTable[] = {
237250
com.android.internal.R.string.same_month_md1_md2,
238251
com.android.internal.R.string.same_month_wday1_md1_wday2_md2,
@@ -259,7 +272,9 @@ public class DateUtils
259272
*
260273
* @more <p>
261274
* e.g. "Sunday" or "January"
275+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
262276
*/
277+
@Deprecated
263278
public static final int LENGTH_LONG = 10;
264279

265280
/**
@@ -268,7 +283,9 @@ public class DateUtils
268283
*
269284
* @more <p>
270285
* e.g. "Sun" or "Jan"
286+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
271287
*/
288+
@Deprecated
272289
public static final int LENGTH_MEDIUM = 20;
273290

274291
/**
@@ -278,14 +295,18 @@ public class DateUtils
278295
* <p>e.g. "Su" or "Jan"
279296
* <p>In most languages, the results returned for LENGTH_SHORT will be the same as
280297
* the results returned for {@link #LENGTH_MEDIUM}.
298+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
281299
*/
300+
@Deprecated
282301
public static final int LENGTH_SHORT = 30;
283302

284303
/**
285304
* Request an even shorter abbreviated version of the name.
286305
* Do not use this. Currently this will always return the same result
287306
* as {@link #LENGTH_SHORT}.
307+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
288308
*/
309+
@Deprecated
289310
public static final int LENGTH_SHORTER = 40;
290311

291312
/**
@@ -295,7 +316,9 @@ public class DateUtils
295316
* <p>e.g. "S", "T", "T" or "J"
296317
* <p>In some languages, the results returned for LENGTH_SHORTEST will be the same as
297318
* the results returned for {@link #LENGTH_SHORT}.
319+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
298320
*/
321+
@Deprecated
299322
public static final int LENGTH_SHORTEST = 50;
300323

301324
/**
@@ -309,7 +332,9 @@ public class DateUtils
309332
* Undefined lengths will return {@link #LENGTH_MEDIUM}
310333
* but may return something different in the future.
311334
* @throws IndexOutOfBoundsException if the dayOfWeek is out of bounds.
335+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
312336
*/
337+
@Deprecated
313338
public static String getDayOfWeekString(int dayOfWeek, int abbrev) {
314339
int[] list;
315340
switch (abbrev) {
@@ -330,7 +355,9 @@ public static String getDayOfWeekString(int dayOfWeek, int abbrev) {
330355
* @param ampm Either {@link Calendar#AM Calendar.AM} or {@link Calendar#PM Calendar.PM}.
331356
* @throws IndexOutOfBoundsException if the ampm is out of bounds.
332357
* @return Localized version of "AM" or "PM".
358+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
333359
*/
360+
@Deprecated
334361
public static String getAMPMString(int ampm) {
335362
Resources r = Resources.getSystem();
336363
return r.getString(sAmPm[ampm - Calendar.AM]);
@@ -345,7 +372,9 @@ public static String getAMPMString(int ampm) {
345372
* Undefined lengths will return {@link #LENGTH_MEDIUM}
346373
* but may return something different in the future.
347374
* @return Localized month of the year.
375+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
348376
*/
377+
@Deprecated
349378
public static String getMonthString(int month, int abbrev) {
350379
// Note that here we use sMonthsMedium for MEDIUM, SHORT and SHORTER.
351380
// This is a shortcut to not spam the translators with too many variations
@@ -378,7 +407,9 @@ public static String getMonthString(int month, int abbrev) {
378407
* but may return something different in the future.
379408
* @return Localized month of the year.
380409
* @hide Pending API council approval
410+
* @deprecated use {@link java.text.SimpleDateFormat} instead.
381411
*/
412+
@Deprecated
382413
public static String getStandaloneMonthString(int month, int abbrev) {
383414
// Note that here we use sMonthsMedium for MEDIUM, SHORT and SHORTER.
384415
// This is a shortcut to not spam the translators with too many variations

0 commit comments

Comments
 (0)