View Javadoc
1   /*
2    * Copyright 2007 Kasper B. Graversen
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.supercsv.cellprocessor.time;
17  
18  import java.time.ZonedDateTime;
19  import java.time.format.DateTimeFormatter;
20  import java.time.format.DateTimeFormatterBuilder;
21  
22  import org.supercsv.cellprocessor.ift.CellProcessor;
23  
24  /**
25   * Converts a ZonedDateTime to a String.
26   * For constructors using DateTimeFormatter, refer to the following
27   * classes:
28   * <ul>
29   * <li>{@link DateTimeFormatter} - formats by pattern and style</li>
30   * <li>{@link DateTimeFormatterBuilder} - complex formats created via method
31   * calls</li>
32   * </ul>
33   *
34   * @author Ludovico Fischer
35   * @since 2.4.0
36   */
37  public class FmtZonedDateTime extends AbstractTemporalAccessorFormattingProcessor<ZonedDateTime> {
38  
39  	/**
40  	 * Constructs a new <tt>FmtZonedDateTime</tt> processor, which formats a
41  	 * ZonedDateTime as a String.
42  	 */
43  	public FmtZonedDateTime() {
44  		super();
45  	}
46  
47  	/**
48  	 * Constructs a new <tt>FmtZonedDateTime</tt> processor, which formats a
49  	 * ZonedDateTime as a String, then calls the next processor in the chain.
50  	 *
51  	 * @param next next processor in the chain
52  	 * @throws NullPointerException if next is null
53  	 */
54  	public FmtZonedDateTime(final CellProcessor next) {
55  		super(next);
56  	}
57  
58  	/**
59  	 * Constructs a new <tt>FmtZonedDateTime</tt> processor, which formats a
60  	 * ZonedDateTime as a String using the supplied formatter.
61  	 *
62  	 * @param formatter the formatter to use
63  	 * @throws NullPointerException if formatter is null
64  	 */
65  	public FmtZonedDateTime(final DateTimeFormatter formatter) {
66  		super(formatter);
67  	}
68  
69  	/**
70  	 * Constructs a new <tt>FmtZonedDateTime</tt> processor, which formats a
71  	 * ZonedDateTime as a String using the supplied formatter, then calls the next
72  	 * processor in the chain.
73  	 *
74  	 * @param formatter the formatter to use
75  	 * @param next      the next processor in the chain
76  	 * @throws NullPointerException if formatter or next is null
77  	 */
78  	public FmtZonedDateTime(final DateTimeFormatter formatter, final CellProcessor next) {
79  		super(formatter, next);
80  	}
81  
82  	@Override
83  	protected Class<ZonedDateTime> getType() {
84  		return ZonedDateTime.class;
85  	}
86  }