mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
Support long month names, dot after day, single digit day of month
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1923081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9eda246398
commit
4962a04bbf
@ -78,8 +78,8 @@ public class DateUtil {
|
||||
private static final Pattern date_ptrn5 = Pattern.compile("^\\[DBNum([123])]");
|
||||
|
||||
private static final DateTimeFormatter dateTimeFormats = new DateTimeFormatterBuilder()
|
||||
.appendPattern("[dd MMM[ yyyy]][[ ]h:m[:s][.SSS] a][[ ]H:m[:s][.SSS]]")
|
||||
.appendPattern("[[yyyy ]dd-MMM[-yyyy]][[ ]h:m[:s][.SSS] a][[ ]H:m[:s][.SSS]]")
|
||||
.appendPattern("[d[.] [MMMM][MMM][ yyyy]][[ ]h:m[:s][.SSS] a][[ ]H:m[:s][.SSS]]")
|
||||
.appendPattern("[[yyyy ]d-[MMMM][MMM][-yyyy]][[ ]h:m[:s][.SSS] a][[ ]H:m[:s][.SSS]]")
|
||||
.appendPattern("[M/dd[/yyyy]][[ ]h:m[:s][.SSS] a][[ ]H:m[:s][.SSS]]")
|
||||
.appendPattern("[[yyyy/]M/dd][[ ]h:m[:s][.SSS] a][[ ]H:m[:s][.SSS]]")
|
||||
.parseDefaulting(ChronoField.YEAR_OF_ERA, LocaleUtil.getLocaleCalendar().get(Calendar.YEAR))
|
||||
|
||||
@ -29,9 +29,13 @@ import org.apache.poi.ss.formula.eval.NumberEval;
|
||||
import org.apache.poi.ss.formula.eval.StringEval;
|
||||
import org.apache.poi.ss.formula.eval.ValueEval;
|
||||
import org.apache.poi.ss.util.Utils;
|
||||
import org.apache.poi.util.LocaleUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Tests for {@link Value}
|
||||
@ -85,6 +89,14 @@ final class TestValue {
|
||||
confirmValue("4:48:00", 0.2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDates() {
|
||||
confirmValue("1 January 2025", 45658);
|
||||
confirmValue("01 January 2025", 45658);
|
||||
confirmValue("1 Jan 2025", 45658);
|
||||
confirmValue("01 Jan 2025", 45658);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testErrors() {
|
||||
confirmValueError("1+1");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user