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.LocalTime; 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 String to a LocalTime. 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 DateTimeFormatter} - ISO 8601 formats</li> 31 * <li>{@link DateTimeFormatterBuilder} - complex formats created via method 32 * calls</li> 33 * </ul> 34 * 35 * @author Ludovico Fischer 36 * @since 2.4.0 37 */ 38 public class ParseLocalTime extends AbstractTemporalAccessorParsingProcessor<LocalTime> { 39 40 /** 41 * Constructs a new <tt>ParseLocalTime</tt> processor, which parses a 42 * String as a LocalTime, accepting the same format as {@link LocalTime#parse(CharSequence)} 43 * 44 */ 45 public ParseLocalTime() { 46 } 47 48 /** 49 * Constructs a new <tt>ParseLocalTime</tt> processor, which parses a 50 * String as a LocalTime, then calls the next processor in the 51 * chain. 52 * 53 * @param next the next processor in the chain 54 * @throws NullPointerException if next is null 55 * @see ParseLocalTime() 56 */ 57 public ParseLocalTime(final CellProcessor next) { 58 super(next); 59 } 60 61 /** 62 * Constructs a new <tt>ParseLocalTime</tt> processor, which parses a 63 * String as a LocalTime using the supplied formatter. 64 * 65 * @param formatter the formatter used for parsing 66 * @throws NullPointerException if formatter is null 67 */ 68 public ParseLocalTime(final DateTimeFormatter formatter) { 69 super(formatter); 70 } 71 72 /** 73 * Constructs a new <tt>ParseLocalTime</tt> processor, which parses a 74 * String as a LocalTime using the supplied formatter, then calls 75 * the next processor in the chain. 76 * 77 * @param formatter the formatter used for parsing 78 * @param next the next processor in the chain 79 * @throws NullPointerException if formatter or next is null 80 */ 81 public ParseLocalTime(final DateTimeFormatter formatter, final CellProcessor next) { 82 super(formatter, next); 83 } 84 85 /** 86 * {@inheritDoc} 87 */ 88 @Override 89 protected LocalTime parse(final String string) { 90 return LocalTime.parse(string); 91 } 92 93 /** 94 * {@inheritDoc} 95 */ 96 @Override 97 protected LocalTime parse(final String string, final DateTimeFormatter formatter) { 98 return LocalTime.parse(string, formatter); 99 } 100 }