I am working on Xero accounts Apis
In json response i am getting date like below
"Date": "/Date(1455447600000+1300)/",
also same date in getting in dateString field like
"DateString": "2016-02-15T00:00:00",
i am trying to convert above date into string but getting different date. as in our api both dates are same, in Date field and DateString field.
Long longDate=Long.valueOf("1455447600000")+Long.valueOf("1300");
Date date = new Date(longDate);
//TimeZone timeZone = TimeZone.getTimeZone("UTC"); //also tried this
Calendar cal=Calendar.getInstance();
cal.setTime(date);
System.out.println(cal.getTime());
output: Sun Feb 14 16:30:01 IST 2016
14 Feb but in StringDate it's 15 Feb
json:
[
{
"Date": "/Date(1455447600000+1300)/",
"Type": "ACCREC",
"Total": 460,
"Status": "AUTHORISED",
"Contact": {
"Name": "nn",
"Phones": [
],
"Addresses": [
],
"ContactID": "6831fd62-d6f1-4dc7-9338-24566074ecf6",
"ContactGroups": [
],
"ContactPersons": [
],
"HasValidationErrors": false
},
"DueDate": "/Date(1455620400000+1300)/",
"Payments": [
],
"SubTotal": 460,
"TotalTax": 0,
"AmountDue": 460,
"HasErrors": false,
"InvoiceID": "dcf1f09e-3e98-443e-981e-cdd9f296d607",
"LineItems": [
{
"TaxType": "OUTPUT",
"ItemCode": "Item2",
"Quantity": 20,
"Tracking": [
],
"TaxAmount": 0,
"LineAmount": 460,
"LineItemID": "2a6c5078-a462-4e8c-b277-d1164885b7d9",
"UnitAmount": 23,
"AccountCode": "200",
"Description": "Item2"
}
],
"Reference": "43223",
"AmountPaid": 0,
"DateString": "2016-02-15T00:00:00",
"CreditNotes": [
],
"Prepayments": [
],
"CurrencyCode": "INR",
"CurrencyRate": 1,
"IsDiscounted": false,
"Overpayments": [
],
"DueDateString": "2016-02-17T00:00:00",
"InvoiceNumber": "INV-0002",
"AmountCredited": 0,
"HasAttachments": false,
"UpdatedDateUTC": "/Date(1455475695503+1300)/",
"LineAmountTypes": "Exclusive"
}
]
See Question&Answers more detail:
os