[JAVA] Difference in date expression due to case inflection

Case inflection-about differences in expressions that change from country to country

Month name

The expressions January and January in English and Japanese do not change in any case.

However, in some languages such as Russian, Czech, Polish and Finnish, there is an inflection of "case inflection". https://ja.wikipedia.org/wiki/%E6%A0%BC%E5%A4%89%E5%8C%96

When expressing "○ month" in the following two ways, the expression method differs depending on the case inflection.

--When writing "○ month" alone --When writing "○ year ○ month" and "○ month ○ day" together with the year and day

Example. Finnish "January" (from http://whitebear0930.net/archives/5097)

Date format Expression
○ Month tammikuu
○ year ○ month etc. tammikuuta

Android provides the ** "L" ** pattern as the date format of the month name to make this expression. If it is "L", the month name when it is used alone can be obtained, and if it is "M", the month name when it is not used alone can be obtained.

Example. Finnish "January"

Date format Expression
MMM tammikuuta
MMMM tammikuuta
LLL tammi
LLLL tammikuu

Use alone & Use LLL if you want to get the abbreviated month name. Note that MMM cannot get the abbreviation. In languages that do not have case inflection (English, Japanese, etc.), L is treated the same as M.

Day of the week

Since there is a case inflection on the day of the week, "** c **" is prepared for the day of the week when used alone.

Example. Finnish "Wednesday"

Date format Expression
E, EE, EEE ke
EEEE keskiviikkona
EEEEE K
EEEEEE ke
c, cc, ccc ke
cccc keskiviikko
ccccc K
cccccc ke

Supplement

Date format

I often forget it, so it's an appendix. There are detailed examples of what characters are used and how many are used. I think the table in android.icu.text.SimpleDateFormat is easy to understand.

Android date parsing class

There are various classes that parse using date formats such as yyyy / MM / dd when displaying dates on Android.

Depending on the Android version, more can be used. From API 24 (Android 7.0), the android.icu.text package for ICU (International Components for Unicode) has been added.

Starting with API 26 (Android 8.0), the java.time package implemented in Java 8 has been added.

Qiita: Remember this for Java 8 date and time API for the time being http://qiita.com/tag1216/items/91a471b33f383981bfaa

Since java.text.SimpleDateFormat has different behavior between Java version and Android version, be careful about the difference in behavior from Java version when developing on Android.

Qiita: How to write SimpleDateFormat is different between Android and Java http://qiita.com/arai-wa/items/272c9a09386872b8c643

Looking at the reference in java.text.SimpleDateFormat, L and c are not listed in the date format pattern table, but they are correct. You can use it.

Recommended Posts

Difference in date expression due to case inflection
How to implement date calculation in Java
How to get date data in Ruby
How to fix system date in JUnit
How to get the date in java
About batch processing performance due to difference in primary key generation method in JPA
How to solve an Expression Problem in Java
[Java] I want to calculate the difference from the date
Change date and time to Japanese notation in Rails
How to write a date comparison search in Rails
I want to stop snake case in table definition
[Ruby/Rails] How to generate a password in a regular expression