com.regnosys.rosetta.translate.basic.DateParseHandler Maven / Gradle / Ivy
package com.regnosys.rosetta.translate.basic;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import com.rosetta.model.lib.records.Date;
public class DateParseHandler extends BasicParseHandler {
private DateTimeFormatter pattern;
public DateParseHandler(boolean allowsMultiple, boolean isCondition, boolean removeHtml) {
super(allowsMultiple, isCondition, removeHtml);
this.pattern = DateTimeFormatter.ISO_LOCAL_DATE;
}
public DateParseHandler(boolean allowsMultiple, boolean isCondition, boolean removeHtml, String pattern) {
super(allowsMultiple, isCondition, removeHtml);
this.pattern = DateTimeFormatter.ofPattern(pattern);
}
@Override
public String toString() {
return "Date";
}
@Override
protected Date convert(String value) {
return Date.of(LocalDate.parse(value, pattern));
}
}