1 /* 2 * Copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos 3 * 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * * Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * 12 * * Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * * Neither the name of JSR-310 nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 package org.threeten.bp.format; 33 34 import java.util.Locale; 35 36 import org.threeten.bp.chrono.Chronology; 37 38 /** 39 * The Service Provider Interface (SPI) to be implemented by classes providing 40 * date-time formatting information. 41 * 42 * <h3>Specification for implementors</h3> 43 * This interface is a service provider that can be called by multiple threads. 44 * Implementations must be thread-safe. 45 * Implementations should cache the returned formatters. 46 */ 47 abstract class DateTimeFormatStyleProvider { 48 49 /** 50 * Gets the provider. 51 * 52 * @return the provider, not null 53 */ getInstance()54 static DateTimeFormatStyleProvider getInstance() { 55 return new SimpleDateTimeFormatStyleProvider(); 56 } 57 58 /** 59 * Gets the available locales. 60 * 61 * @return the locales 62 */ getAvailableLocales()63 public Locale[] getAvailableLocales() { 64 throw new UnsupportedOperationException(); 65 } 66 67 /** 68 * Gets a localized date, time or date-time formatter. 69 * <p> 70 * The formatter will be the most appropriate to use for the date and time style in the locale. 71 * For example, some locales will use the month name while others will use the number. 72 * 73 * @param dateStyle the date formatter style to obtain, null to obtain a time formatter 74 * @param timeStyle the time formatter style to obtain, null to obtain a date formatter 75 * @param chrono the chronology to use, not null 76 * @param locale the locale to use, not null 77 * @return the date-time formatter, not null 78 * @throws IllegalArgumentException if both format styles are null 79 * @throws IllegalArgumentException if the locale is not a recognized locale 80 */ getFormatter( FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale)81 public abstract DateTimeFormatter getFormatter( 82 FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale); 83 84 } 85