[JAVA] Trial and error to display national holidays in Android application development. Part 1

Thanks! This is Yosuke. Since one screen of the diary app is finally over, I was on a day trip mini trip for about 10 hours. I was enthusiastic that I would take a lot of pictures with a single-lens reflex camera, but I could hardly take pictures ... I was just tired and it was a lot of days, such as being run over by a careless car in front and behind on my way home ( Lol).   This time, if the day incorporated in the diary application is a national holiday, display it and tap it to display the details in a dialog. I will introduce that in the first part and the second part.

--National holidays --Holidays with fixed dates --Holiday on the 0th Monday --Spring and autumn equinox --Transfer holiday

National holidays

First, let's write down the national holidays in Japan. ** New Year's Day, Adult Day, National Foundation Day, Emperor's Birthday, Spring Day, Showa Day, Constitution Day, Greenery Day, Children's Day, Marine Day, Mountain Day, Keiro Day, Autumnal Equinox Day There are 16 days, Sports Day, Culture Day, and Labor Thanksgiving Day **. "Health Sports Day" was changed to "Sports Day" in 2020. Next, we will talk about dates that will be important in the program.

Holidays with fixed dates

This is a list of holidays that have a programmatically easy date set from the beginning.

Holiday name date Remarks
New Year's Day January 1 -
Foundation Day February 11 -
The emperor's birthday February 23 -
Showa Day April 29 -
Constitution Memorial Day May 3 -
Greenery day May 4th -
Children's day May 5th -
Mountain day August 11 August 10, 2020
Culture Day November 3rd -
Labor Thanksgiving Day November 23 -

0th Monday holiday

Holiday name date Remarks
Coming of age day 2nd Monday of January -
Marine day 3rd Monday of July July 23, 2020
Respect for the aged day 3rd Monday of September -
Sports day 2nd monday in october July 24, 2020

As shown in the table above, holidays will move in 2020, when the Olympics and Paralympics are held, but it seems that we can somehow determine it because we know the month, week, and day of the week.

Spring equinox and autumn equinox

These two holidays were a nuisance. First, the spring equinox day is one of the 19th to 22nd of March, and the autumnal equinox day is one of the 22nd to 24th of September. The reason why the days differ depending on the year seems to be related to the orbital period of the earth, so please see here for details. ). Do I have to enter the spring and autumn equinox days while looking at the calendar one by one? At first, I dropped my shoulders, but according to Wikipedia, the days of the spring and autumn equinoxes of that year can be decided by dividing the year by four. Vernal Equinox Day: https://en.wikipedia.org/wiki/%E6%98%A5%E5%88%86%E3%81%AE%E6%97%A5 Autumnal Equinox Day: https://en.wikipedia.org/wiki/%E7%A7%8B%E5%88%86%E3%81%AE%E6%97%A5

Substitute holiday

Substitute holidays are a bit confusing as "the day after a national holiday that is not a national holiday after the Monday following the national holiday Sunday," but the holiday law states that. Simply put, if Sunday is a holiday, it may be better to think that the next weekday will be used for the transfer holiday.

In the second part, it is hard to say that it is an explanation with the idea and the source code actually written, but I think I will explain it. I will raise it within this week, so thank you.

References

Holiday Law: https://www8.cao.go.jp/chosei/shukujitsu/gaiyou.html National Holidays: https://en.wikipedia.org/wiki/%E5%9B%BD%E6%B0%91%E3%81%AE%E7%A5%9D%E6%97%A5

Recommended Posts

Trial and error to display national holidays in Android application development. Part 1
[Android application development] How to display in full screen (notification bar hidden)
Introduction to Android application development
How to implement one-line display of TextView in Android development
Java to C and C to Java in Android Studio
How to display error messages in Japanese
[In team development] Error when moving to another member's branch and doing rails s [Rails]
[Personal application work memo] How to display a bar graph and a line graph in one graph
[Introduction to Android application development] Let's make a counter
Android application development preparation 7/15
Implementation policy to dynamically save and display Timezone in Rails
Android app to select and display images from the gallery
Reasons to use Servlet and JSP separately in Java development
[Android] Try to display the effect on the touched part of the screen, which is common in games.
A newcomer tries to summarize the Android view (beginner Android application development)
What I have learned in Java (Part 1) Java development flow and overview
Source to display character array with numberPicker in Android studio (Java)
What to do if you get a DISPLAY error in gym.render ()
Install Rails in the development environment and create a new application
[Android] Convert Map to JSON using GSON in Kotlin and Java
Introduction to Android App Development 1 Installing JDK and Android Studio for mac