1 /*
2 * Copyright 2001-2014 Stephen Colebourne
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.joda.time.format;
17
18 import java.io.IOException;
19 import java.util.Locale;
20
21 import org.joda.time.Chronology;
22 import org.joda.time.DateTimeZone;
23 import org.joda.time.ReadablePartial;
24
25 /**
26 * Internal interface for creating textual representations of datetimes.
27 * <p>
28 * This has been separated from {@link DateTimePrinter} to avoid code duplication.
29 *
30 * @author Stephen Colebourne
31 * @since 2.4
32 */
33 interface InternalPrinter {
34
35 /**
36 * Returns the expected maximum number of characters produced.
37 * The actual amount should rarely exceed this estimate.
38 *
39 * @return the estimated length
40 */
41 int estimatePrintedLength();
42
43 //-----------------------------------------------------------------------
44 /**
45 * Prints an instant from milliseconds since 1970-01-01T00:00:00Z,
46 * using the given Chronology.
47 *
48 * @param appendable formatted instant is appended to, not null
49 * @param instant millis since 1970-01-01T00:00:00Z
50 * @param chrono the chronology to use, not null
51 * @param displayOffset if a time zone offset is printed, force it to use
52 * this millisecond value
53 * @param displayZone the time zone to use, null means local time
54 * @param locale the locale to use, null means default locale
55 */
56 void printTo(Appendable appendable, long instant, Chronology chrono,
57 int displayOffset, DateTimeZone displayZone, Locale locale) throws IOException;
58
59 /**
60 * Prints a ReadablePartial.
61 *
62 * @param appendable formatted instant is appended to, not null
63 * @param partial partial to format, not null
64 * @param locale the locale to use, null means default locale
65 */
66 void printTo(Appendable appendable, ReadablePartial partial, Locale locale) throws IOException;
67
68 }
69