javasimpledateformat

simple date format with leading space instead of zero


I need a simple Date format that can give leading space instead of zero for the Day of month (d)

My current code using below date format.

SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy");

Restult i am getting is                        Wed Nov 04 05:55:15 2015
Restult i am getting for double digit days as  Wed Nov 14 05:55:15 2015 

Wed Nov (space in place of zero)4 05:55:15 2015 for single digit day of month

Wed Nov 14 05:55:15 2015 for double digit month of day.

Please help. is there any date format in java to get this format?


Solution

  • Finally I solved with some logic.splitting the Date using spaces and appending the Space in front of day of month,if it is single digit and combine all.Otherwise no change.