Class TimeEmojifier
java.lang.Object
de.gustavblass.fsu.fmi.roombooking.util.TimeEmojifier
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents two emoji for one specific hour on a 12-day clock. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final @NonNull Map<Integer, TimeEmojifier.HourEmoji> All clock emoji in the Unicode standard.private static final @NonNull DurationOne half of an hour (i.e. 30 minutes).private static final @NonNull DurationA quarter of an hour (i.e. 15 minutes).private static final @NonNull DurationThree quarters of an hour (i.e. 45 minutes). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static @NonNull LocalTimeroundToHalfHour(@NonNull LocalTime time) Replaces the
part of the giveninvalid reference
LocalTime#minuteLocalTimewith either `00:00` or `00:30`, depending onwhether the minute part is closer to the full hour or closer to the half hour.
static @NonNull StringtoClockEmoji(@NonNull LocalTime time) Converts a givenLocalTimeto a fitting clock emoji.
-
Field Details
-
quarterHour
A quarter of an hour (i.e. 15 minutes). -
threeQuartersHour
Three quarters of an hour (i.e. 45 minutes). -
halfHour
One half of an hour (i.e. 30 minutes). -
emojiMap
All clock emoji in the Unicode standard.
-
-
Constructor Details
-
TimeEmojifier
public TimeEmojifier()
-
-
Method Details
-
toClockEmoji
@Contract(pure=true) @NonNull public static @NonNull String toClockEmoji(@NonNull @NonNull LocalTime time) Converts a given
LocalTimeto a fitting clock emoji.If the
part is closer to the hour, then theinvalid reference
LocalTime#minuteTimeEmojifier.HourEmoji.onHour()emoji for the specific houris returned, otherwise the
TimeEmojifier.HourEmoji.halfHour()].- Parameters:
time- The time that shall be converted to an emoji. Works for both 12-hour- and 24-hour-based clocks.- Returns:
- A fitting clock emoji for the given time.
-
roundToHalfHour
@Contract(pure=true) @NonNull private static @NonNull LocalTime roundToHalfHour(@NonNull @NonNull LocalTime time) Replaces the
part of the giveninvalid reference
LocalTime#minuteLocalTimewith either `00:00` or `00:30`, depending onwhether the minute part is closer to the full hour or closer to the half hour. For example,
09:24becomes09:30, while17:46becomes18:00.The given time is shifted at most by 15 minutes.
- Parameters:
time- The time to be rounded.- Returns:
- The same time, rounded to the closest full or half hour.
-