Fix NPE when formatting date strings