greekTimeLiteralToEnglish property
String
get
greekTimeLiteralToEnglish
Replaces the Greek 12-hour time literals with the English 12-hour time literals. πμ -> pm -> AM (ante meridiem / before mesembria / before noon) μμ -> mm -> PM (post meridiem / after mesembria / after noon)
For example:
05/12/2023 05:45:17 μ.μ.
will return
05/12/2023 05:45:17 PM
Implementation
String get greekTimeLiteralToEnglish {
// If the String does not contain any Greek characters, return it as is.
if (!this.containsAnyGreekCharacter) {
return this;
}
// Translate all the Greek letters to the equivalent English ones.
String onlyEnglishCharacters = this.replaceGreek.trim();
// Transform to the equivalent English time literals.
onlyEnglishCharacters =
onlyEnglishCharacters.replaceAll(".", "").toLowerCase();
onlyEnglishCharacters = onlyEnglishCharacters.contains("pm")
? onlyEnglishCharacters.replaceAll("pm", "AM")
: onlyEnglishCharacters.replaceAll("mm", "PM");
return onlyEnglishCharacters;
}