2020-01-05 17:24:43 +01:00
|
|
|
/*
|
2020-08-14 23:21:38 +02:00
|
|
|
* Copyright (C) 2019-2020 Christian Pierre MOMON <christian.momon@devinsy.fr>
|
2020-01-05 17:24:43 +01:00
|
|
|
*
|
2020-08-14 23:21:38 +02:00
|
|
|
* This file is part of AgirStatool, simple key value database.
|
2020-01-05 17:24:43 +01:00
|
|
|
*
|
2020-08-14 23:21:38 +02:00
|
|
|
* AgirStatool is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2020-01-05 17:24:43 +01:00
|
|
|
*
|
2020-08-14 23:21:38 +02:00
|
|
|
* AgirStatool is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2020-01-05 17:24:43 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2020-08-14 23:21:38 +02:00
|
|
|
* along with AgirStatool. If not, see <http://www.gnu.org/licenses/>.
|
2020-01-05 17:24:43 +01:00
|
|
|
*/
|
|
|
|
package org.april.agirstatool.core;
|
|
|
|
|
2020-02-05 18:52:42 +01:00
|
|
|
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;
|
|
|
|
|
2020-01-05 17:24:43 +01:00
|
|
|
import org.apache.log4j.BasicConfigurator;
|
|
|
|
import org.apache.log4j.Level;
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
import org.junit.AfterClass;
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class JugaTest.
|
|
|
|
*
|
|
|
|
* @author Christian Pierre MOMON
|
|
|
|
*/
|
2020-08-14 23:21:38 +02:00
|
|
|
public class AgirStatoolTest
|
2020-01-05 17:24:43 +01:00
|
|
|
{
|
2020-08-14 23:21:38 +02:00
|
|
|
private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AgirStatoolTest.class);
|
2020-01-05 17:24:43 +01:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testExport01() throws Exception
|
|
|
|
{
|
|
|
|
//
|
|
|
|
logger.debug("===== test starting...");
|
|
|
|
|
|
|
|
//
|
|
|
|
logger.debug("===== test done.");
|
|
|
|
}
|
|
|
|
|
2020-02-05 18:52:42 +01:00
|
|
|
@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.");
|
|
|
|
}
|
|
|
|
|
2020-01-05 17:24:43 +01:00
|
|
|
/**
|
|
|
|
* After class.
|
|
|
|
*
|
|
|
|
* @throws AgirStatoolException
|
|
|
|
* the Juga exception
|
|
|
|
*/
|
|
|
|
@AfterClass
|
|
|
|
public static void afterClass() throws AgirStatoolException
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Before class.
|
|
|
|
*
|
|
|
|
* @throws AgirStatoolException
|
|
|
|
* the Juga exception
|
|
|
|
*/
|
|
|
|
@BeforeClass
|
|
|
|
public static void beforeClass() throws AgirStatoolException
|
|
|
|
{
|
|
|
|
BasicConfigurator.configure();
|
|
|
|
Logger.getRootLogger().setLevel(Level.DEBUG);
|
|
|
|
}
|
|
|
|
}
|