LocaleBasedJodaTimeConverter { public Locale getLocale() { Locale locale = localization.getLocale(); if (locale == null) { locale = Locale.getDefault(); } return locale; } LocaleBasedJodaTimeConverter(Localization localization); DateTime convert(String value, DateTimeFormatter formatter); Locale getLocale();  }
@Test public void shouldUseTheDefaultLocale() throws ParseException { when(request.getSession()).thenReturn(session); when(request.getAttribute("javax.servlet.jsp.jstl.fmt.locale.request")).thenReturn(null); when(session.getAttribute("javax.servlet.jsp.jstl.fmt.locale.session")). thenReturn(null); when(context.getAttribute("javax.servlet.jsp.jstl.fmt.locale.application")). thenReturn(null); when(context.getInitParameter("javax.servlet.jsp.jstl.fmt.locale")). thenReturn(null); when(request.getLocale()).thenReturn(new Locale("pt_BR")); assertThat(new Locale("pt_BR"), is(equalTo(converter.getLocale()))); }
@Test public void shouldUseTheDefaulJvmtLocale() throws ParseException { when(request.getSession()).thenReturn(session); when(request.getAttribute("javax.servlet.jsp.jstl.fmt.locale.request")).thenReturn(null); when(session.getAttribute("javax.servlet.jsp.jstl.fmt.locale.session")). thenReturn(null); when(context.getAttribute("javax.servlet.jsp.jstl.fmt.locale.application")). thenReturn(null); when(context.getInitParameter("javax.servlet.jsp.jstl.fmt.locale")). thenReturn(null); when(request.getLocale()).thenReturn(null); assertThat(Locale.getDefault(), is(equalTo(converter.getLocale()))); }