Ensure that DateTimeFormatter doesn't format an empty string

This fixes #4393 and maintains BC.