8300307: Refactor code examples to use @snippet in java.text.DateFormat

Reviewed-by: lancea, iris, naoto
This commit is contained in:
Justin Lu 2023-01-18 23:09:46 +00:00 committed by Naoto Sato
parent 601e0ae7da
commit dfe94b89f8

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -74,28 +74,28 @@ import sun.util.locale.provider.LocaleServiceProviderPool;
* <p>To format a date for the current Locale, use one of the * <p>To format a date for the current Locale, use one of the
* static factory methods: * static factory methods:
* <blockquote> * <blockquote>
* <pre>{@code * {@snippet lang=java :
* myString = DateFormat.getDateInstance().format(myDate); * myString = DateFormat.getDateInstance().format(myDate);
* }</pre> * }
* </blockquote> * </blockquote>
* <p>If you are formatting multiple dates, it is * <p>If you are formatting multiple dates, it is
* more efficient to get the format and use it multiple times so that * more efficient to get the format and use it multiple times so that
* the system doesn't have to fetch the information about the local * the system doesn't have to fetch the information about the local
* language and country conventions multiple times. * language and country conventions multiple times.
* <blockquote> * <blockquote>
* <pre>{@code * {@snippet lang=java :
* DateFormat df = DateFormat.getDateInstance(); * DateFormat df = DateFormat.getDateInstance();
* for (int i = 0; i < myDate.length; ++i) { * for (int i = 0; i < myDate.length; ++i) {
* output.println(df.format(myDate[i]) + "; "); * output.println(df.format(myDate[i]) + "; ");
* } * }
* }</pre> * }
* </blockquote> * </blockquote>
* <p>To format a date for a different Locale, specify it in the * <p>To format a date for a different Locale, specify it in the
* call to {@link #getDateInstance(int, Locale) getDateInstance()}. * call to {@link #getDateInstance(int, Locale) getDateInstance()}.
* <blockquote> * <blockquote>
* <pre>{@code * {@snippet lang=java :
* DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE); * DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE);
* }</pre> * }
* </blockquote> * </blockquote>
* *
* <p>If the specified locale contains "ca" (calendar), "rg" (region override), * <p>If the specified locale contains "ca" (calendar), "rg" (region override),
@ -106,9 +106,9 @@ import sun.util.locale.provider.LocaleServiceProviderPool;
* *
* <p>You can use a DateFormat to parse also. * <p>You can use a DateFormat to parse also.
* <blockquote> * <blockquote>
* <pre>{@code * {@snippet lang=java :
* myDate = df.parse(myString); * myDate = df.parse(myString);
* }</pre> * }
* </blockquote> * </blockquote>
* <p>Use {@code getDateInstance} to get the normal date format for that country. * <p>Use {@code getDateInstance} to get the normal date format for that country.
* There are other static factory methods available. * There are other static factory methods available.
@ -697,9 +697,9 @@ public abstract class DateFormat extends Format {
/** /**
* Sets the time zone for the calendar of this {@code DateFormat} object. * Sets the time zone for the calendar of this {@code DateFormat} object.
* This method is equivalent to the following call. * This method is equivalent to the following call.
* <blockquote><pre>{@code * <blockquote>{@snippet lang=java :
* getCalendar().setTimeZone(zone) * getCalendar().setTimeZone(zone);
* }</pre></blockquote> * }</blockquote>
* *
* <p>The {@code TimeZone} set by this method is overwritten by a * <p>The {@code TimeZone} set by this method is overwritten by a
* {@link #setCalendar(java.util.Calendar) setCalendar} call. * {@link #setCalendar(java.util.Calendar) setCalendar} call.
@ -717,9 +717,9 @@ public abstract class DateFormat extends Format {
/** /**
* Gets the time zone. * Gets the time zone.
* This method is equivalent to the following call. * This method is equivalent to the following call.
* <blockquote><pre>{@code * <blockquote>{@snippet lang=java :
* getCalendar().getTimeZone() * getCalendar().getTimeZone();
* }</pre></blockquote> * }</blockquote>
* *
* @return the time zone associated with the calendar of DateFormat. * @return the time zone associated with the calendar of DateFormat.
*/ */
@ -735,9 +735,9 @@ public abstract class DateFormat extends Format {
* inputs must match this object's format. * inputs must match this object's format.
* *
* <p>This method is equivalent to the following call. * <p>This method is equivalent to the following call.
* <blockquote><pre>{@code * <blockquote>{@snippet lang=java :
* getCalendar().setLenient(lenient) * getCalendar().setLenient(lenient);
* }</pre></blockquote> * }</blockquote>
* *
* <p>This leniency value is overwritten by a call to {@link * <p>This leniency value is overwritten by a call to {@link
* #setCalendar(java.util.Calendar) setCalendar()}. * #setCalendar(java.util.Calendar) setCalendar()}.
@ -753,9 +753,9 @@ public abstract class DateFormat extends Format {
/** /**
* Tell whether date/time parsing is to be lenient. * Tell whether date/time parsing is to be lenient.
* This method is equivalent to the following call. * This method is equivalent to the following call.
* <blockquote><pre>{@code * <blockquote>{@snippet lang=java :
* getCalendar().isLenient() * getCalendar().isLenient();
* }</pre></blockquote> * }</blockquote>
* *
* @return {@code true} if the {@link #calendar} is lenient; * @return {@code true} if the {@link #calendar} is lenient;
* {@code false} otherwise. * {@code false} otherwise.