I am receiving date in my android application from google spreadsheet through appscript and i am receiving this data in yyyy-dd-MM'T'HH:mm:ss.SSS'Z'
this format and I dont know why because in spreadsheet date is in dd-MM-YYYY
this format but the main issue is when receiving date from spreadsheet month MM
is decremented by one and also if it is 01
it becomes 31
which creates an error in my application while parsing the format.
Please tell me how to stop this decrementing of month value.
Asked
Active
Viewed 30 times
0

Rubén
- 34,714
- 9
- 70
- 166

Vestrol007
- 27
- 1
- 10
-
Can you provide your code? How to you parse the date? – Patrick Santana Apr 08 '20 at 09:16
1 Answers
1
I don't know how you retrieve and send the data with Apps Script, but
Apps Script features the method Utilities.formatDate
that allows to format the data before processing it further.
Sample:
var sheet = SpreadsheetApp.getActive().getActiveSheet();
var date = sheet.getRange('A1').getValue();
var formattedDate = Utilities.formatDate(date, "GMT+2", "dd-MM-yyyy");
- It is important to specify the time zone, because otherwise the date might be retrieved / passed incorrectly.
- Also: if you use
YYYY
instead ofyyyy
- ming that it would be the calendar-based year.

ziganotschka
- 25,866
- 2
- 16
- 33