how to get subscription expire date in inapp v3 android

I want to give Ans to my own que's ans, So that if some one looking for the same can find the solution. After lots of google I did not find a exact solution I was looking for So I create a method in BillingProcessor class in iabv3 library project which returns a Bundle with Purchases details, in which i get the purchased date. Now I am able to find the expiry date with this. The method looks like below

public Bundle getPurchases(){
    if (!isInitialized())
        return null;
    try{
        return  billingService.getPurchases(Constants.GOOGLE_API_VERSION, contextPackageName, Constants.PRODUCT_TYPE_SUBSCRIPTION, null);
    }catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

I'm using this:

@Nullable
public Date getSubscriptionRenewingDate(String sku) {

    // Get the Purchase object:
    Purchase purchase = null;
    Purchase.PurchasesResult purchasesResult = _billingClient.queryPurchases(BillingClient.SkuType.SUBS);
    if (purchasesResult.getPurchasesList() != null) {
        for (Purchase p : purchasesResult.getPurchasesList()) {
            if (p.getSku().equals(sku) && p.getPurchaseState() == Purchase.PurchaseState.PURCHASED && p.isAutoRenewing()) {
                purchase = p;
                break;
            }
        }
    }

    // Get the SkuDetails object:
    SkuDetails skuDetails = null;
    for (SkuDetails s : _skuDetails) { // _skuDetails is an array of SkuDetails retrieved with querySkuDetailsAsync
        if (s.getSku().equals(sku)) {
            skuDetails = s;
            break;
        }
    }

    if (purchase != null && skuDetails != null) {

        Date purchaseDate = new Date(purchase.getPurchaseTime());
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(purchaseDate);

        Date now = new Date();

        while (calendar.getTime().before(now)) {

            switch (skuDetails.getSubscriptionPeriod()) {

                case "P1W": calendar.add(Calendar.HOUR, 7*24); break;
                case "P1M": calendar.add(Calendar.MONTH, 1); break;
                case "P3M": calendar.add(Calendar.MONTH, 3); break;
                case "P6M": calendar.add(Calendar.MONTH, 6); break;
                case "P1Y": calendar.add(Calendar.YEAR, 1); break;
            }
        }

        return calendar.getTime();
    }

    return null;
}

I have used this code for getting the purchase details in the Billing Processor Library .

   TransactionDetails transactionDetails = bp.getSubscriptionTransactionDetails(channelModel.getAndroidProductId());
        Log.d(TAG, "initializePaymentSetup: " + transactionDetails.toString());
        Log.d(TAG, "initializePaymentSetup: " + transactionDetails.purchaseInfo.toString());

 transactionDetails.purchaseInfo.purchaseData// this will return the purchase date