Reputation: 311
In-App purchase response, as purchase time, how to convert this timestamp to date format, the problem I am facing is the value of timestamp is exceeding long data type limit? kindly explain how to finad the date from timestamp in this case?
Upvotes: 4
Views: 2341
Reputation: 922
val timeStamp = purchase.purchaseTime
val date = Date(timeStamp)
val calendar = Calendar.getInstance()
calendar.time = date
calendar.add(Calendar.DATE,30)
Timber.tag("TIMES").d(calendar.time.toString())
purchase
is a Purchase object. You should now be able to tell your user when their next billing period will be.Upvotes: 0
Reputation: 2573
You are trying to parse a timestamp with SimpleDateFormat using an incorrect format string "MMddyyHHmmss". The timestamp value returned is expressed in "milliseconds since the epoch (Jan 1, 1970)". Parse the string to its long value and create a Date object directly from that:
Date date = new Date(Long.parseLong(timestampString));
Upvotes: 6