Fixed damned year alignment.

This commit is contained in:
Christian P. MOMON 2020-02-05 18:52:42 +01:00
parent a444973113
commit 9f6ff3a9cf
2 changed files with 35 additions and 2 deletions

View File

@ -577,7 +577,7 @@ public class AgirStatoolUtils
} }
else else
{ {
result = source.format(DateTimeFormatter.ofPattern("yyyyww", Locale.FRANCE)); result = source.format(DateTimeFormatter.ofPattern("YYYYww", Locale.FRANCE));
} }
// //

View File

@ -18,10 +18,16 @@
*/ */
package org.april.agirstatool.core; package org.april.agirstatool.core;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.SignStyle;
import java.time.temporal.IsoFields;
import java.util.Locale;
import org.apache.log4j.BasicConfigurator; import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.april.agirstatool.core.AgirStatoolException;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -45,6 +51,33 @@ public class JugaTest
logger.debug("===== test done."); logger.debug("===== test done.");
} }
@Test
public void testWeek() throws Exception
{
//
logger.debug("===== test starting...");
System.out.println("==> " + LocalDate.now().getDayOfWeek());
System.out.println("==> " + LocalDate.now().getDayOfWeek().getValue());
System.out.println("==> " + AgirStatoolUtils.normaliseWeekDate(LocalDate.now()));
System.out.println("==> " + AgirStatoolUtils.toYearWeek(LocalDate.of(2019, 12, 30)));
System.out.println(LocalDate.of(2019, 12, 30).format(DateTimeFormatter.ofPattern("yyyyww", Locale.FRENCH)));
System.out.println(LocalDate.of(2019, 12, 30).format(DateTimeFormatter.ofPattern("YYYYww", Locale.FRENCH)));
System.out.println(LocalDate.of(2019, 12, 30).format(DateTimeFormatter.ISO_WEEK_DATE));
DateTimeFormatter weekDateFormatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendValue(IsoFields.WEEK_BASED_YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
.appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2)
.toFormatter(Locale.FRANCE);
System.out.println(LocalDate.of(2019, 12, 30).format(weekDateFormatter));
//
logger.debug("===== test done.");
}
/** /**
* After class. * After class.
* *