Search in sources :

Example 1 with LocaleHelper

use of org.pentaho.platform.util.messages.LocaleHelper in project pentaho-platform by pentaho.

the class LocaleHelperTest method testLocaleHelper.

@Test
public void testLocaleHelper() {
    LocaleHelper helper = new LocaleHelper();
    Assert.assertNotNull(helper);
    Locale myLocale = Locale.US;
    Locale newLocale = Locale.FRANCE;
    LocaleHelper.setDefaultLocale(myLocale);
    Locale myDefaultLocale = LocaleHelper.getDefaultLocale();
    Assert.assertEquals(myDefaultLocale, myLocale);
    LocaleHelper.setLocale(newLocale);
    Locale myNewLocale = LocaleHelper.getLocale();
    Assert.assertEquals(myNewLocale, newLocale);
    // $NON-NLS-1$
    LocaleHelper.setSystemEncoding("UTF8");
    String systemEncoding = LocaleHelper.getSystemEncoding();
    // $NON-NLS-1$
    Assert.assertEquals(systemEncoding, "UTF8");
    // $NON-NLS-1$
    LocaleHelper.setTextDirection("English");
    String textDirection = LocaleHelper.getTextDirection();
    // $NON-NLS-1$
    Assert.assertEquals(textDirection, "English");
    DateFormat dateFormat = LocaleHelper.getDateFormat(LocaleHelper.FORMAT_MEDIUM, LocaleHelper.FORMAT_MEDIUM);
    String format = dateFormat.format(new Date());
    Assert.assertNotNull(format);
    DateFormat fullDateFormat0 = LocaleHelper.getFullDateFormat(false, false);
    Assert.assertNull(fullDateFormat0);
    DateFormat fullDateFormat = LocaleHelper.getFullDateFormat(true, true);
    String format1 = fullDateFormat.format(new Date());
    Assert.assertNotNull(format1);
    DateFormat fullDateFormat1 = LocaleHelper.getFullDateFormat(true, false);
    String format2 = fullDateFormat1.format(new Date());
    Assert.assertNotNull(format2);
    DateFormat fullDateFormat2 = LocaleHelper.getFullDateFormat(false, true);
    String format3 = fullDateFormat2.format(new Date());
    Assert.assertNotNull(format3);
    DateFormat longDateFormat = LocaleHelper.getLongDateFormat(true, true);
    String format4 = longDateFormat.format(new Date());
    Assert.assertNotNull(format4);
    DateFormat longDateFormat1 = LocaleHelper.getLongDateFormat(true, false);
    String format5 = longDateFormat1.format(new Date());
    Assert.assertNotNull(format5);
    DateFormat longDateFormat2 = LocaleHelper.getLongDateFormat(false, true);
    String format6 = longDateFormat2.format(new Date());
    Assert.assertNotNull(format6);
    DateFormat mediumDateFormat = LocaleHelper.getMediumDateFormat(true, true);
    String format7 = mediumDateFormat.format(new Date());
    Assert.assertNotNull(format7);
    DateFormat mediumDateFormat1 = LocaleHelper.getMediumDateFormat(true, false);
    String format8 = mediumDateFormat1.format(new Date());
    Assert.assertNotNull(format8);
    DateFormat mediumDateFormat2 = LocaleHelper.getMediumDateFormat(false, true);
    String format9 = mediumDateFormat2.format(new Date());
    Assert.assertNotNull(format9);
    DateFormat shortDateFormat = LocaleHelper.getShortDateFormat(true, true);
    String format10 = shortDateFormat.format(new Date());
    Assert.assertNotNull(format10);
    DateFormat shortDateFormat1 = LocaleHelper.getMediumDateFormat(true, false);
    String format11 = shortDateFormat1.format(new Date());
    Assert.assertNotNull(format11);
    DateFormat shortDateFormat2 = LocaleHelper.getMediumDateFormat(false, true);
    String format12 = shortDateFormat2.format(new Date());
    Assert.assertNotNull(format12);
}
Also used : Locale(java.util.Locale) LocaleHelper(org.pentaho.platform.util.messages.LocaleHelper) DateFormat(java.text.DateFormat) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DateFormat (java.text.DateFormat)1 Date (java.util.Date)1 Locale (java.util.Locale)1 Test (org.junit.Test)1 LocaleHelper (org.pentaho.platform.util.messages.LocaleHelper)1