All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.excel.tools.validator.cell.LocalDateValidator Maven / Gradle / Ivy

The newest version!
package me.excel.tools.validator.cell;

import me.excel.tools.model.excel.ExcelCell;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

/**
 * local date validator
 * 

* Created by hanwen on 5/3/16. */ public class LocalDateValidator extends CellValidatorAdapter { private String format; public LocalDateValidator(String matchField, String format) { super(matchField, "格式应该为: " + format); this.format = format; } public LocalDateValidator(String matchField, String format, String errorMessage) { super(matchField, errorMessage); this.format = format; } @Override protected boolean customValidate(ExcelCell excelCell) { DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(format); try { dateTimeFormatter.parseLocalDate(excelCell.getValue()); } catch (IllegalArgumentException e) { return false; } return true; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy