-
-
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.
Remove properties files for this part already covered by ICU4J
- Loading branch information
Showing
8 changed files
with
68 additions
and
79 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
50 changes: 50 additions & 0 deletions
50
common/src/main/java/io/github/jy95/fds/common/functions/DayOfWeekFormatter.java
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,50 @@ | ||
package io.github.jy95.fds.common.functions; | ||
|
||
import com.ibm.icu.text.DateFormatSymbols; | ||
import com.ibm.icu.util.Calendar; | ||
|
||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
/** | ||
* Class to format day of week | ||
*/ | ||
public final class DayOfWeekFormatter { | ||
|
||
/** | ||
* Map each code of <a href="https://build.fhir.org/valueset-days-of-week.html">Day Of Week</a> to their ICU4J values | ||
*/ | ||
private static final Map<String, Integer> DAY_MAPPING = Map.ofEntries( | ||
Map.entry("mon", Calendar.MONDAY), | ||
Map.entry("tue", Calendar.TUESDAY), | ||
Map.entry("wed", Calendar.WEDNESDAY), | ||
Map.entry("thu", Calendar.THURSDAY), | ||
Map.entry("fri", Calendar.FRIDAY), | ||
Map.entry("sat", Calendar.SATURDAY), | ||
Map.entry("sun", Calendar.SUNDAY) | ||
); | ||
|
||
/** | ||
* Bundle that contains translations | ||
*/ | ||
private final String[] longWeekDays; | ||
|
||
/** | ||
* Constructor for the formatter | ||
* @param locale The locale to use | ||
*/ | ||
public DayOfWeekFormatter(Locale locale) { | ||
longWeekDays = DateFormatSymbols | ||
.getInstance(locale) | ||
.getWeekdays(); | ||
} | ||
|
||
/** | ||
* Translates a single-day code into its corresponding day of the week in text. | ||
* @param code The <a href="https://build.fhir.org/valueset-days-of-week.html">Day Of Week</a> code to translate | ||
* @return the translated day of the week as a string. | ||
*/ | ||
public String codeToLongText(String code) { | ||
return longWeekDays[DAY_MAPPING.get(code)]; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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