diff options
| author | Kalle Lindström <karl.lindstrom@mullvad.net> | 2025-02-25 10:48:50 +0100 |
|---|---|---|
| committer | Kalle Lindström <karl.lindstrom@mullvad.net> | 2025-02-26 09:25:17 +0100 |
| commit | da304ffedf8f8d98600f31f737cf92768c0323fa (patch) | |
| tree | e8da9b9a861f3d3efbbbc39fb5160ec1cfeb67fa /android/lib/daemon-grpc/src | |
| parent | 5025db74b34cfb3536c43f89f3407ffc0d97ae73 (diff) | |
| download | mullvadvpn-da304ffedf8f8d98600f31f737cf92768c0323fa.tar.xz mullvadvpn-da304ffedf8f8d98600f31f737cf92768c0323fa.zip | |
Remove Joda Time and use java.time package instead
Joda Time has been superseded by the Java 8 java.time package
which has more or less the same API. This commit removes all
usage of Joda Time and replaces it with the java.time classes.
This is done so that we can remove the dependency on Joda Time.
Diffstat (limited to 'android/lib/daemon-grpc/src')
| -rw-r--r-- | android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt index fe4cf11881..717bf401f4 100644 --- a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt +++ b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt @@ -5,6 +5,8 @@ package net.mullvad.mullvadvpn.lib.daemon.grpc.mapper import io.grpc.ConnectivityState import java.net.InetAddress import java.net.InetSocketAddress +import java.time.Instant +import java.time.ZoneId import java.util.UUID import mullvad_daemon.management_interface.ManagementInterface import net.mullvad.mullvadvpn.lib.daemon.grpc.GrpcConnectivityState @@ -72,7 +74,6 @@ import net.mullvad.mullvadvpn.lib.model.WireguardConstraints import net.mullvad.mullvadvpn.lib.model.WireguardEndpointData import net.mullvad.mullvadvpn.lib.model.WireguardRelayEndpointData import net.mullvad.mullvadvpn.lib.model.WireguardTunnelOptions -import org.joda.time.Instant internal fun ManagementInterface.TunnelState.toDomain(): TunnelState = when (stateCase!!) { @@ -570,8 +571,10 @@ internal fun ManagementInterface.Relay.toDomain( } else false, ) +private fun Instant.atDefaultZone() = atZone(ZoneId.systemDefault()) + internal fun ManagementInterface.Device.toDomain(): Device = - Device(DeviceId.fromString(id), name, Instant.ofEpochSecond(created.seconds).toDateTime()) + Device(DeviceId.fromString(id), name, Instant.ofEpochSecond(created.seconds).atDefaultZone()) internal fun ManagementInterface.DeviceState.toDomain(): DeviceState = when (state) { @@ -587,13 +590,13 @@ internal fun ManagementInterface.DeviceState.toDomain(): DeviceState = internal fun ManagementInterface.AccountData.toDomain(): AccountData = AccountData( AccountId(UUID.fromString(id)), - expiryDate = Instant.ofEpochSecond(expiry.seconds).toDateTime(), + expiryDate = Instant.ofEpochSecond(expiry.seconds).atDefaultZone(), ) internal fun ManagementInterface.VoucherSubmission.toDomain(): RedeemVoucherSuccess = RedeemVoucherSuccess( timeAdded = secondsAdded, - newExpiryDate = Instant.ofEpochSecond(newExpiry.seconds).toDateTime(), + newExpiryDate = Instant.ofEpochSecond(newExpiry.seconds).atDefaultZone(), ) internal fun ManagementInterface.SplitTunnelSettings.toDomain(): SplitTunnelSettings = |
