Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.superwall.sdk.models.product
import com.superwall.sdk.models.serialization.BigDecimalSerializer
import com.superwall.sdk.store.abstractions.product.StoreProductType
import com.superwall.sdk.store.abstractions.product.SubscriptionPeriod
import com.superwall.sdk.utilities.DateUtils
import com.superwall.sdk.utilities.localizedDateFormat
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import java.math.BigDecimal
Expand Down Expand Up @@ -221,7 +223,7 @@ data class StripeProductType(
}

override val trialPeriodEndDateString: String
get() = trialPeriodEndDate?.toString() ?: ""
get() = trialPeriodEndDate?.let { localizedDateFormat(DateUtils.MMM_dd_yyyy).format(it) } ?: ""

override val trialPeriodDays: Int
get() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.android.billingclient.api.ProductDetails.SubscriptionOfferDetails
import com.superwall.sdk.billing.DecomposedProductIds
import com.superwall.sdk.contrib.threeteen.AmountFormats
import com.superwall.sdk.utilities.DateUtils
import com.superwall.sdk.utilities.dateFormat
import com.superwall.sdk.utilities.localizedDateFormat
import kotlinx.serialization.Transient
import org.threeten.bp.Period
import java.math.BigDecimal
Expand Down Expand Up @@ -488,7 +488,7 @@ class RawStoreProduct(

override val trialPeriodEndDateString by lazy {
trialPeriodEndDate?.let {
val dateFormatter = dateFormat(DateUtils.MMM_dd_yyyy)
val dateFormatter = localizedDateFormat(DateUtils.MMM_dd_yyyy)
dateFormatter.format(it)
} ?: ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ internal object DateUtils {

internal fun dateFormat(format: String = DateUtils.ISO_MILLIS) = SimpleDateFormat(format, Locale.US)

internal fun localizedDateFormat(format: String = DateUtils.MMM_dd_yyyy) = SimpleDateFormat(format, Locale.getDefault())

internal val DateFormatterUtil = dateFormat()
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class ProductFetcherInstrumentedTest {

val currentDate = LocalDate.now()
val dateIn30Days = currentDate.plusMonths(1)
val dateFormatter = DateTimeFormatter.ofPattern(DateUtils.MMM_dd_yyyy, Locale.US)
val dateFormatter = DateTimeFormatter.ofPattern(DateUtils.MMM_dd_yyyy, Locale.getDefault())
val formattedDate = dateIn30Days.format(dateFormatter)
println("Comparing -${storeProduct.trialPeriodEndDateString}- with -$formattedDate-")
assertEquals(formattedDate, storeProduct.trialPeriodEndDateString)
Expand Down Expand Up @@ -398,7 +398,7 @@ class ProductFetcherInstrumentedTest {

val currentDate = LocalDate.now()
val dateIn30Days = currentDate.plusMonths(1)
val dateFormatter = DateTimeFormatter.ofPattern(DateUtils.MMM_dd_yyyy, Locale.US)
val dateFormatter = DateTimeFormatter.ofPattern(DateUtils.MMM_dd_yyyy, Locale.getDefault())
val formattedDate = dateIn30Days.format(dateFormatter)
assertEquals(formattedDate, storeProduct.trialPeriodEndDateString)
}
Expand Down Expand Up @@ -448,7 +448,7 @@ class ProductFetcherInstrumentedTest {

val currentDate = LocalDate.now()
val dateIn30Days = currentDate.plusMonths(1)
val dateFormatter = DateTimeFormatter.ofPattern(DateUtils.MMM_dd_yyyy, Locale.US)
val dateFormatter = DateTimeFormatter.ofPattern(DateUtils.MMM_dd_yyyy, Locale.getDefault())
val formattedDate = dateIn30Days.format(dateFormatter)
assertEquals(formattedDate, storeProduct.trialPeriodEndDateString)
}
Expand Down Expand Up @@ -500,7 +500,7 @@ class ProductFetcherInstrumentedTest {

val currentDate = LocalDate.now()
val dateIn30Days = currentDate.plusMonths(1)
val dateFormatter = DateTimeFormatter.ofPattern(DateUtils.MMM_dd_yyyy, Locale.US)
val dateFormatter = DateTimeFormatter.ofPattern(DateUtils.MMM_dd_yyyy, Locale.getDefault())
val formattedDate = dateIn30Days.format(dateFormatter)
assertEquals(formattedDate, storeProduct.trialPeriodEndDateString)
}
Expand Down Expand Up @@ -553,7 +553,7 @@ class ProductFetcherInstrumentedTest {

val currentDate = LocalDate.now()
val dateIn30Days = currentDate.plusMonths(1)
val dateFormatter = DateTimeFormatter.ofPattern(DateUtils.MMM_dd_yyyy, Locale.US)
val dateFormatter = DateTimeFormatter.ofPattern(DateUtils.MMM_dd_yyyy, Locale.getDefault())
val formattedDate = dateIn30Days.format(dateFormatter)
assertEquals(formattedDate, storeProduct.trialPeriodEndDateString)
}
Expand Down
Loading