Wednesday, January 15, 2014

format date




Well two small issues.




- you're running into the Calendar Month Trap; it starts counting at January = month 0! You need to add 1 to the month that Calendar returns, but that would then format as "1" and not "01".



- you need to print numbers that consist of a single digit as two digits, you can't blindly append them to the String




BUT! You are already using a SimpleDateFormatter to PARSE the date, might you not also use a SimpleDateFormatter to FORMAT the date in the way you want?







No comments:

Post a Comment