1

Android Billing API shows a period in the following format

P1M - 1 month
P1Y - 1 year
P2W - 2 weeks
P3D - 3 days

Is it standardized format and are there utils to format it to human-readable strings? Or I need to reinvent the wheel and do it myself.

jakub
  • 3,576
  • 3
  • 29
  • 55

1 Answers1

0

add this library

 implementation 'com.jakewharton.threetenabp:threetenabp:1.2.4'

use this method

import org.threeten.bp.Period

   fun getFreeTialDays(freeTrialPeriod: String): String {
        return Period.parse(freeTrialPeriod).days.toString()
    }
   //this will give in days , you can use days

inside Period.parse() there are days,months and years . you can use them or you can convert days according to your requirement

Manohar
  • 22,116
  • 9
  • 108
  • 144