I implemented a biziclop solution. - He works.
If someone is interested, here it is:
import static org.junit.Assert.assertEquals; import java.text.DateFormat; import java.text.DateFormatSymbols; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import org.junit.Test; public class DateFormatTest { private static final Locale locale = Locale.ENGLISH; private final DateFormatSymbols addDotToAbbricationMonths(final DateFormatSymbols dateFormatSymbols) { String[] shortMonths = dateFormatSymbols.getShortMonths(); for (int i = 0; i < shortMonths.length; i++) { if (dateFormatSymbols.getMonths()[i].length() > shortMonths[i].length()) { shortMonths[i] += '.'; } } dateFormatSymbols.setShortMonths(shortMonths); return dateFormatSymbols; } final DateFormat format = new SimpleDateFormat("MMM yyyy", addDotToAbbricationMonths(new DateFormatSymbols(locale))); @Test public void testShortEnought() { Date firstMay = new GregorianCalendar(2010, Calendar.MAY, 1).getTime(); assertEquals("May 2010", format.format(firstMay)); } @Test public void testToLong() { Date firstDecember = new GregorianCalendar(2010, Calendar.DECEMBER, 1).getTime(); assertEquals("Dec. 2010", format.format(firstDecember)); } @Test public void noInfluence() { Date firstDecember = new GregorianCalendar(2010, Calendar.DECEMBER, 1).getTime(); assertEquals("Dec 2010", new SimpleDateFormat("MMM yyyy", locale).format(firstDecember)); } }
Ralph
source share