Skip to content

Conversation

@ianrumac
Copy link
Collaborator

@ianrumac ianrumac commented Jan 26, 2026

Changes in this pull request

  • Fix date locale formatting for trial in products

Checklist

  • All unit tests pass.
  • All UI tests pass.
  • Demo project builds and runs.
  • I added/updated tests or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have run ktlint in the main directory and fixed any issues.
  • I have updated the SDK documentation as well as the online docs.
  • I have reviewed the contributing guide

Greptile Overview

Greptile Summary

This PR fixes trial period end date formatting to respect the user's device locale instead of always using US locale. Previously, trialPeriodEndDateString would always format dates in US format (e.g., "Jan 15, 2026") regardless of the device's locale settings. Now it uses the device's default locale, ensuring dates appear in the format users expect based on their regional settings.

Key changes:

  • Added new localizedDateFormat() utility function that uses Locale.getDefault() instead of Locale.US
  • Updated RawStoreProduct.trialPeriodEndDateString to use localized formatting
  • Fixed StripeProductType.trialPeriodEndDateString which was incorrectly using Date.toString() (would produce a format like "Wed Jan 15 00:00:00 GMT 2026")
  • Updated all related tests to validate against localized date format

This is a user-facing improvement that ensures proper internationalization of trial period dates displayed in paywalls.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward and well-tested. The PR adds proper locale support for date formatting, improving internationalization. All tests have been updated to match the new behavior, and the change is backwards-compatible in terms of functionality (dates still display correctly, just in the user's preferred format).
  • No files require special attention

Important Files Changed

Filename Overview
superwall/src/main/java/com/superwall/sdk/utilities/DateUtils.kt Added localizedDateFormat() function to format dates using device locale instead of hardcoded US locale
superwall/src/main/java/com/superwall/sdk/store/abstractions/product/RawStoreProduct.kt Updated trialPeriodEndDateString to use localizedDateFormat() for proper locale formatting
superwall/src/main/java/com/superwall/sdk/models/product/StripeProductType.kt Updated trialPeriodEndDateString to use localizedDateFormat() instead of Date.toString()
superwall/src/test/java/com/superwall/sdk/products/ProductFetcherTest.kt Updated test assertions to use Locale.getDefault() to match the new localized date formatting behavior

Sequence Diagram

sequenceDiagram
    participant Paywall
    participant StoreProduct
    participant RawStoreProduct
    participant StripeProductType
    participant DateUtils
    
    Paywall->>StoreProduct: Access trialPeriodEndDateString
    StoreProduct->>RawStoreProduct: Get trialPeriodEndDateString
    RawStoreProduct->>RawStoreProduct: Check trialPeriodEndDate
    RawStoreProduct->>DateUtils: Call localizedDateFormat(MMM_dd_yyyy)
    DateUtils-->>RawStoreProduct: Return SimpleDateFormat with Locale.getDefault()
    RawStoreProduct->>RawStoreProduct: Format date
    RawStoreProduct-->>StoreProduct: Return formatted date string
    StoreProduct-->>Paywall: Return localized date (e.g., "Jan 15, 2026")
    
    Note over Paywall,DateUtils: Alternative path for Stripe products
    Paywall->>StripeProductType: Access trialPeriodEndDateString
    StripeProductType->>StripeProductType: Check trialPeriodEndDate
    StripeProductType->>DateUtils: Call localizedDateFormat(MMM_dd_yyyy)
    DateUtils-->>StripeProductType: Return SimpleDateFormat with Locale.getDefault()
    StripeProductType->>StripeProductType: Format date
    StripeProductType-->>Paywall: Return localized date string
Loading

@ianrumac ianrumac merged commit e079253 into develop Jan 26, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants