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