Q:

Convert mediumDate() to other format (with Locale) on Joda-Time

I've a problem to convert a date in other format in java (I'm using Joda-Time). In fact, I've a formatted local date as is:
24/giu/14 (Italian format date...but other local formats are possible)

I would like to see this in output (using Locale format date):
24/06/2014

I tried to build a sample code, but doesn't works...what am I doing wrong?
public String DateConvertFromMediumFormatToSlash (String date)
    {
        DateTimeFormatter dtf = DateTimeFormat.mediumDate().withLocale(Locale.getDefault());
        LocalDate dt = dtf.parseLocalDate(date);

        return dt.toString(); // output: 2014-06-24
    }

A:

Your question is confusing with regards to what you have as input and what you want as output.
Italy Uses Hyphens, Not Slashes
But one problem seems to be the slashes. Joda-Time expects hyphens not slashes. Here is some example code using Joda-Time 2.3 showing you what a LocalDate looks like as a String using the medium format for Locale of Italy.
LocalDate localDate = new LocalDate( 2014, 6, 24 );
System.out.println( "localDate: " + localDate );

DateTimeFormatter formatter = DateTimeFormat.mediumDate().withLocale( Locale.ITALY );
System.out.println( "output: " + formatter.print( localDate ) );

When run…
localDate: 2014-06-24
output: 24-giu-2014

Define A Formatter For Slashes
So if you want to parse/generate a string with slashes instead of the hyphens expected for Locale of Italy, you must explicitly define such a formatter.
String input = "24/giu/14";
DateTimeFormatter formatterInput = DateTimeFormat.forPattern( "dd/MMM/yy").withLocale( Locale.ITALY );
LocalDate localDate = formatterInput.parseLocalDate( input );
System.out.println( "localDate: " + localDate );

DateTimeFormatter formatterOutput = DateTimeFormat.forPattern( "dd/MM/yy").withLocale( Locale.ITALY ); // Locale not needed here, but it's a good habit to specify.
String output = formatterOutput.print( localDate );
System.out.println( "Output: " + output );

When run…
localDate: 2014-06-24
Output: 24/06/14

By the way, using two digits for the year is asking for trouble IMHO.

