Remove Leading "0" in day of month SimpleDateFormat

39,174
SimpleDateFormat formatter = new SimpleDateFormat("EEEE', 'MMMM d', ' yyyy");

Should do it (one 'd' instead of two)?

http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

Share:
39,174
Denoteone
Author by

Denoteone

I have 12 years of professional experience efficiently coding websites, web applications, and CMS plugins using current web technologies like PHP, Angular 2, and CSS(3) to list a few examples. Building state-of-the-art, easy to use, user-friendly websites and applications that have valid and efficient code is truly a passion of mine In addition to my knowledge base, I actively seek out new technologies and stay up-to-date on industry trends and advancements. Denoteone @ Miaou

Updated on July 05, 2022

Comments

  • Denoteone
    Denoteone almost 2 years

    Is it possible to remove the "0" in January 04, 2012?

    I am currently using the following Java to get the date format like

    Monday, January 04, 2012
    

    I would like for it to look like

    Monday, January 4, 2012
    
        Date anotherCurDate = new Date();
    
        SimpleDateFormat formatter = new SimpleDateFormat("EEEE', 'MMMM dd', ' yyyy");  
        final String formattedDateString = formatter.format(anotherCurDate);
    
     final TextView currentRoomDate = (TextView)  this.findViewById(R.id.CurrentDate); 
    
  • Denoteone
    Denoteone over 12 years
    Of course it would be that easy. I figured there was going to be some post process to fix it. Thanks I will test now.
  • Jave
    Jave over 12 years
    Hehe, it's called 'simple' date formatter for a reason ;) I added a link to the documentation for it, in case you haven't seen it.
  • Tom Howard
    Tom Howard almost 3 years
    The explicit use of single format specifiers is articulated in this Oracle tutorial... docs.oracle.com/javase/tutorial/i18n/format/…