-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
138 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
DateUtilsCompat | ||
--- | ||
|
||
[![Download](https://api.bintray.com/packages/kuluna/maven/dateutilscompat/images/download.svg) ](https://bintray.com/kuluna/maven/dateutilscompat/_latestVersion) | ||
|
||
Androidの言語設定に従って2つの日付の範囲を文字列にフォーマットします。 | ||
Androidの[DateUtils.formatDateRange]は日本語のみ出力結果が微妙に異なります。 | ||
|
||
- 同じ日付の場合は 4月29日 13時37分~15時37分 | ||
- 日付が異なる場合 4月29日 13:37~4月30日 13:37 | ||
- 年が異なる場合 2020年4月29日 13:37~2021年4月29日 13:37 | ||
|
||
と「時分」と「:」の2パターンが出力されてしまいます。DateUtilsCompatはそのどちらかに揃えて出力します。日本語以外はオリジナルのDateUtilsと同じ動きをします。 | ||
|
||
# Install | ||
``` | ||
implementation 'jp.kuluna:dateutilscompat:1.0.0' | ||
``` | ||
# Usage | ||
|
||
```kotlin | ||
// DateUtils.formatDateTime(context, start, DateUtils.FORMAT_SHOW_DATE. or DateUtils.FORMAT_SHOW_TIME) | ||
|
||
DateUtilsCompat.formatDateTime(context, start, DateUtils.FORMAT_SHOW_DATE or DateUtils.FORMAT_SHOW_TIME) | ||
// 4月29日 13:37 | ||
|
||
// DateUtils.formatDateRange(context, start, end, DateUtils.FORMAT_SHOW_DATE. or DateUtils.FORMAT_SHOW_TIME) | ||
|
||
DateUtilsCompat.formatDateRange(context, start, end, DateUtils.FORMAT_SHOW_DATE. or DateUtils.FORMAT_SHOW_TIME) | ||
// 4月29日 13:37分~15:37 | ||
``` | ||
|
||
## Custom | ||
```kotlin | ||
DateUtilsCompat.formatDateTime(context, start, DateUtils.FORMAT_SHOW_DATE. or DateUtils.FORMAT_SHOW_TIME, DateUtilsCompat.COLON) | ||
// 4月29日 13:37 | ||
|
||
DateUtilsCompat.formatDateTime(context, start, DateUtils.FORMAT_SHOW_DATE. or DateUtils.FORMAT_SHOW_TIME, DateUtilsCompat.KANJI) | ||
// 4月29日 13時37分 | ||
``` | ||
|
||
# License | ||
MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters