Java date format real simple

datejavastring

how would you write te date if i have a date and all i want is the month and the day like this (mm/dd) and then turn the month like this July, 08

Best Answer

Let me see if I understood well.

You have a date like "07/08" and you want "July, 08"?

You could try SimpleDateFormat

import java.text.SimpleDateFormat;
import java.text.ParseException;

class Test {
    public static void main( String [] args ) throws ParseException  {

        SimpleDateFormat in  = new SimpleDateFormat("MM/dd");
        SimpleDateFormat out = new SimpleDateFormat("MMMM, dd");

        System.out.println( out.format( in.parse("07/08") ) );

        // Verbose 
        //String input = "07/09";           
        //Date  date = in.parse( input );  
        //String output = out.format( date );
        //System.out.println( output );
    }
}