🎌 Japanese holiday for Java
- Java 7 or later
repositories {
jcenter()
}
dependencies {
compile 'com.github.holidayjp:holidayjp:2.0.0'
}LocalDate, LocalDateTime, ZonedDateTime and OffsetDateTime classes are supported.
compile 'com.github.holidayjp:holidayjp-jdk8:2.0.0'LocalDate, LocalDateTime and DateTime classes are supported.
compile 'com.github.holidayjp:holidayjp-joda:2.0.0'ThreeTenABP is polyfill of Java 8 Date and Time API for Android. LocalDate, LocalDateTime, ZonedDateTime and OffsetDateTime classes are supported.
implementation 'com.github.holidayjp:holidayjp-threetenabp:2.0.0'import java.util.*;
import com.github.holidayjp.HolidayJp;
Date today = new Date();
if (HolidayJp.isHoliday(today)) {
System.out.println("Today is a holiday!");
}import java.time.*;
import com.github.holidayjp.jdk8.HolidayJp;
LocalDate today = LocalDate.now();
if (HolidayJp.isHoliday(today)) {
System.out.println("Today is a holiday!");
}The library is compatible with Android (>= API level 15).
import org.threeten.bp.*
import com.github.holidayjp.threetenabp.HolidayJp
val today = LocalDate.now()
if (HolidayJp.isHoliday(today)) {
println("Today is a holiday!")
}This is utility class for Java 7 or earlier.
Judge whether it is a holiday in Japan. If a date is holiday, return true.
ymd parameter should be formatted YYYY-MM-DD.
import com.github.holidayjp.HolidayJp;
if (HolidayJp.isHoliday("2018-12-01")) {
System.out.println("2018/12/01 is a holiday!");
}Judge whether it is a holiday in Japan. If a date is holiday, return true.
import com.github.holidayjp.HolidayJp;
if (HolidayJp.isHoliday(2018, 12, 1)) {
System.out.println("2018/12/01 is a holiday!");
}Judge whether it is a holiday in Japan. If a date is holiday, return true.
import java.util.*;
import com.github.holidayjp.HolidayJp;
Date today = new Date();
if (HolidayJp.isHoliday(today)) {
System.out.println("Today is a holiday!");
}Judge whether it is a holiday in Japan. If a date is holiday, return true.
timeZone parameter is used to judge holiday.
import java.util.*;
import com.github.holidayjp.HolidayJp;
Calendar calendar = Calendar.getInstance();
TimeZone timeZone = TimeZone.getTimeZone("UTC");
calendar.setTimeZone(timeZone);
Date today = calendar.getTime();
if (HolidayJp.isHoliday(today, timeZone)) {
System.out.println("Today is a holiday!");
}Judge whether it is a holiday in Japan. If a date is holiday, return true.
The time zone setting of calendar is used to judge holiday.
import java.util.*;
import com.github.holidayjp.HolidayJp;
Calendar calendar = Calendar.getInstance();
if (HolidayJp.isHoliday(calendar)) {
System.out.println("Today is a holiday!");
}Holiday class represents holiday data.
import java.util.*;
import com.github.holidayjp.Holiday;
import com.github.holidayjp.HolidayJp;
Calendar calendar = Calendar.getInstance();
calendar.set(2015, 9 - 1, 23);
Date date = calendar.getTime();
Holiday holiday = HolidayJp.between(date, and: date)[0];
System.out.println(holiday.getYmd()); // "2015-09-23"
System.out.println(holiday.getWeek()); // "火"
System.out.println(holiday.getWeekEn()); // "Tuesday"
System.out.println(holiday.getName()); // "秋分の日"
System.out.println(holiday.getNameEn()); // "Autumnal Equinox Day"This is utility class for Java 8 or later.
Judge whether it is a holiday in Japan. If a date is holiday, return true.
import java.time.*;
import com.github.holidayjp.jdk8.HolidayJp;
LocalDate today = LocalDate.now();
if (HolidayJp.isHoliday(today)) {
System.out.println("Today is a holiday!");
}This is utility class for Joda-Time.
Judge whether it is a holiday in Japan. If a date is holiday, return true.
import org.joda.time.*;
import com.github.holidayjp.joda.HolidayJp;
LocalDate today = LocalDate.now();
if (HolidayJp.isHoliday(today)) {
System.out.println("Today is a holiday!");
}This is utility class for ThreeTenABP.
Judge whether it is a holiday in Japan. If a date is holiday, return true.
import org.threeten.bp.*;
import com.github.holidayjp.threetenabp.HolidayJp;
LocalDate today = LocalDate.now();
if (HolidayJp.isHoliday(today)) {
System.out.println("Today is a holiday!");
}Please run gradle task to re-generate holidays definitions.
$ ./gradlew generate
$ ./gradlew check connectedCheck
$ export BINTRAY_USER=username
$ export BINTRAY_API_KEY=apiKey
$ ./gradlew clean assemble bintrayUpload
MIT © Pine Mizune