JS Excel to SimpleDateFormat

October 2014
Semantic Code

Google Sheets uses an implementation of Excel’s date format to display cells that contain dates in a specific way. Unfortunately, Google currently doesn’t provide a way, through apps scripting, to use the date format syntax that can be extracted from the spreadsheet because Utilities.formatDate() requires Java’s simpleDateFormat and does not support the Excel format. I wrote this function that will convert the Excel format to simpleDateFormat.

I attempted to implement most of the functionality provided by the Excel date format syntax, but not all of it had a direct analog with the simpleDateFormat syntax like single letter months and different cases of AM/PM. Please contact me if you have any ideas to make this better or come across any bugs.

Visit Project