File tree Expand file tree Collapse file tree 4 files changed +21
-2
lines changed
src/main/kotlin/box/tapsi/libs/utilities/time Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ and formatting tools to accelerate development and maintain consistency across p
7171<dependency >
7272 <groupId >box.tapsi.libs</groupId >
7373 <artifactId >utilities-starter</artifactId >
74- <version >0.9.3 </version >
74+ <version >0.9.4 </version >
7575</dependency >
7676```
7777
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ plugins {
1010}
1111
1212group = " box.tapsi.libs"
13- version = " 0.9.3 "
13+ version = " 0.9.4 "
1414description = " utilities-starter"
1515
1616repositories {
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import java.time.DayOfWeek
44import java.time.Duration
55import java.time.Instant
66import java.time.LocalDate
7+ import java.time.LocalDateTime
78import java.time.LocalTime
89import java.util.concurrent.TimeUnit
910
@@ -103,6 +104,18 @@ interface TimeOperator {
103104 */
104105 fun convertLocalDateToInstant (localDate : LocalDate , timezone : SupportedTimezone = SupportedTimezone .Tehran ): Instant
105106
107+ /* *
108+ * Converts a LocalDateTime to an Instant using the provided timezone.
109+ *
110+ * @param localDateTime the LocalDateTime object to be converted.
111+ * @param timezone the timezone to be used for the conversion. Defaults to SupportedTimezone.Tehran.
112+ * @return the corresponding Instant representation of the provided LocalDateTime in the specified timezone.
113+ */
114+ fun convertLocalDateTimeToInstant (
115+ localDateTime : LocalDateTime ,
116+ timezone : SupportedTimezone = SupportedTimezone .Tehran ,
117+ ): Instant
118+
106119 /* *
107120 * Retrieves the current local date based on the specified timezone.
108121 *
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import java.time.DayOfWeek
44import java.time.Duration
55import java.time.Instant
66import java.time.LocalDate
7+ import java.time.LocalDateTime
78import java.time.LocalTime
89import java.util.concurrent.TimeUnit
910
@@ -52,6 +53,11 @@ class TimeOperatorImpl : TimeOperator {
5253 timezone : SupportedTimezone ,
5354 ): Instant = localDate.atStartOfDay(timezone.asZoneId()).toInstant()
5455
56+ override fun convertLocalDateTimeToInstant (
57+ localDateTime : LocalDateTime ,
58+ timezone : SupportedTimezone ,
59+ ): Instant = localDateTime.atZone(timezone.asZoneId()).toInstant()
60+
5561 override fun getCurrentLocalDate (timezone : SupportedTimezone ): LocalDate = LocalDate .now(timezone.asZoneId())
5662
5763 override fun getCurrentDayOfWeek (timezone : SupportedTimezone ): DayOfWeek = getCurrentLocalDate(timezone).dayOfWeek
You can’t perform that action at this time.
0 commit comments