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.joda; 17 18 import org.joda.time.LocalDateTime; 19 import org.joda.time.format.DateTimeFormat; 20 import org.joda.time.format.DateTimeFormatter; 21 import org.joda.time.format.DateTimeFormatterBuilder; 22 import org.joda.time.format.ISODateTimeFormat; 23 import org.supercsv.cellprocessor.ift.CellProcessor; 24 25 /** 26 * Converts a String to a Joda LocalDateTime. 27 * 28 * <p> 29 * For constructors using DateTimeFormatter, refer to the following Joda 30 * classes: 31 * <ul> 32 * <li>{@link DateTimeFormat} - formats by pattern and style</li> 33 * <li>{@link ISODateTimeFormat} - ISO8601 formats</li> 34 * <li>{@link DateTimeFormatterBuilder} - complex formats created via method 35 * calls</li> 36 * </ul> 37 * <p> 38 * For constructors using date format Strings, refer to {@link DateTimeFormat} 39 * for example formats. 40 * 41 * @since 2.3.0 42 * @author James Bassett 43 */ 44 public class ParseLocalDateTime extends 45 AbstractJodaParsingProcessor<LocalDateTime> { 46 47 /** 48 * Constructs a new <tt>ParseLocalDateTime</tt> processor, which parses a 49 * String as a Joda LocalDateTime. 50 */ 51 public ParseLocalDateTime() { 52 } 53 54 /** 55 * Constructs a new <tt>ParseLocalDateTime</tt> processor, which parses a 56 * String as a Joda LocalDateTime, then calls the next processor in the 57 * chain. 58 * 59 * @param next 60 * the next processor in the chain 61 * @throws NullPointerException 62 * if next is null 63 */ 64 public ParseLocalDateTime(final CellProcessor next) { 65 super(next); 66 } 67 68 /** 69 * Constructs a new <tt>ParseLocalDateTime</tt> processor, which parses a 70 * String as a Joda LocalDateTime using the supplied formatter. 71 * 72 * @param formatter 73 * the formatter used for parsing 74 * @throws NullPointerException 75 * if formatter is null 76 */ 77 public ParseLocalDateTime(final DateTimeFormatter formatter) { 78 super(formatter); 79 } 80 81 /** 82 * Constructs a new <tt>ParseLocalDateTime</tt> processor, which parses a 83 * String as a Joda LocalDateTime using the supplied formatter, then calls 84 * the next processor in the chain. 85 * 86 * @param formatter 87 * the formatter used for parsing 88 * @param next 89 * the next processor in the chain 90 * @throws NullPointerException 91 * if formatter or next is null 92 */ 93 public ParseLocalDateTime(final DateTimeFormatter formatter, 94 final CellProcessor next) { 95 super(formatter, next); 96 } 97 98 /** 99 * {@inheritDoc} 100 */ 101 @Override 102 protected LocalDateTime parse(final String string) { 103 return LocalDateTime.parse(string); 104 } 105 106 /** 107 * {@inheritDoc} 108 */ 109 @Override 110 protected LocalDateTime parse(final String string, 111 final DateTimeFormatter formatter) { 112 return LocalDateTime.parse(string, formatter); 113 } 114 }