agirstatool/test/org/april/agirstatool/core/JugaTest.java

105 lines
3.0 KiB
Java

/*
* Copyright (C) 2019 Christian Pierre MOMON, DEVINSY
*
* This file is part of Juga, simple key value database.
*
* Juga 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.
*
* Juga 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.
*
* You should have received a copy of the GNU Affero General Public License
* along with Juga. If not, see <http://www.gnu.org/licenses/>.
*/
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.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
*/
public class JugaTest
{
private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(JugaTest.class);
@Test
public void testExport01() throws Exception
{
//
logger.debug("===== test starting...");
//
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.
*
* @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);
}
}