Java Code Examples for java.util.Locale#UK

The following examples show how to use java.util.Locale#UK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiThreadedPersisterTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public void testConcurrency() throws Exception {
   Persister persister = new Persister();
   CountDownLatch latch = new CountDownLatch(20);
   BlockingQueue<Status> status = new LinkedBlockingQueue<Status>();
   Example example = new Example();
   
   example.name = "Eample Name";
   example.value = "Some Value";
   example.number = 10;
   example.date = new Date();
   example.locale = Locale.UK;
   
   for(int i = 0; i < 20; i++) {
      Worker worker = new Worker(latch, persister, status, example);
      worker.start();
   }
   for(int i = 0; i < 20; i++) {
      assertEquals("Serialization fails when used concurrently", status.take(), Status.SUCCESS);
   }
}
 
Example 2
Source File: PeriodAxisTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that the equals() method can distinguish the locale field (which
 * is new in version 1.0.13).
 */
@Test
public void testEqualsWithLocale() {
    PeriodAxis a1 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.JAPAN);
    PeriodAxis a2 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.JAPAN);
    assertTrue(a1.equals(a2));
    assertTrue(a2.equals(a1));

    a1 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.UK);
    assertFalse(a1.equals(a2));
    a2 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.UK);
    assertTrue(a1.equals(a2));
}
 
Example 3
Source File: PeriodAxisTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that the equals() method can distinguish the locale field (which
 * is new in version 1.0.13).
 */
@Test
public void testEqualsWithLocale() {
    PeriodAxis a1 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.JAPAN);
    PeriodAxis a2 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.JAPAN);
    assertTrue(a1.equals(a2));
    assertTrue(a2.equals(a1));

    a1 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.UK);
    assertFalse(a1.equals(a2));
    a2 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.UK);
    assertTrue(a1.equals(a2));
}
 
Example 4
Source File: MailingSendAction.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Write mailing send to user log
 * @param admin — admin
 * @param sendDate — scheduled send date
 * @param aMailing — mailing to send
 */
protected void logSendAction(ComAdmin admin, Date sendDate, Mailing aMailing, int sendActionType) {
    final Locale backendLocale = Locale.UK;
    final String mailingType = mailingTypeToString(aMailing.getMailingType());
    MailingTypes type = MailingTypes.getByCode(aMailing.getMailingType());
    assert(type != null);

    switch (type) {
        case ACTION_BASED:
            writeUserActivityLog(admin, "do activate mailing", "Mailing type: " + mailingType + ". " + getTriggerMailingDescription(aMailing));
            break;

        case DATE_BASED:
            writeUserActivityLog(admin, "do activate mailing", "Mailing type: " + mailingType + ", at: " + DateFormat.getTimeInstance(DateFormat.SHORT, backendLocale).format(sendDate) + ". " + getTriggerMailingDescription(aMailing));
            break;

        default:
            writeUserActivityLog(admin, "do schedule mailing", "Mailing type: " + mailingType + ", at: " + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, backendLocale).format(sendDate) + ". " + getRegularMailingDescription(aMailing, sendActionType));
    }
}
 
Example 5
Source File: PeriodAxisTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Confirm that the equals() method can distinguish the locale field (which
 * is new in version 1.0.13).
 */
@Test
public void testEqualsWithLocale() {
    PeriodAxis a1 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.JAPAN);
    PeriodAxis a2 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.JAPAN);
    assertTrue(a1.equals(a2));
    assertTrue(a2.equals(a1));

    a1 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.UK);
    assertFalse(a1.equals(a2));
    a2 = new PeriodAxis("Test", new Year(2000), new Year(2009),
            TimeZone.getDefault(), Locale.UK);
    assertTrue(a1.equals(a2));
}
 
Example 6
Source File: UnitFormatTest.java    From sis with Apache License 2.0 6 votes vote down vote up
/**
 * Reminder for units parsing and formatting that still need improvement.
 * The "expected" values checked in this method are not really what we expect,
 * but they reflect the current behavior of Apache SIS units library. We keep
 * those tests as a reminder of work to do, but they should be modified if SIS
 * support of those units is improved in a future version.
 *
 * @see <a href="https://issues.apache.org/jira/browse/SIS-378">SIS-378</a>
 */
@Test
public void needForImprovements() {
    final UnitFormat f = new UnitFormat(Locale.UK);
    roundtrip(f, "kg.kg-1.m.s-1",    "m∕s");
    roundtrip(f, "(m2.s.sr)-1",      "1∕(m²⋅s)");
    roundtrip(f, "m-2.s.rad-1",      "s∕m²");
    roundtrip(f, "kg.kg-1.s-1",      "Hz");
    roundtrip(f, "kg/kg*kg/kg",      "kg∕kg");
    roundtrip(f, "W.m-2.Hz-1",       "kg∕s²");
    roundtrip(f, "W.sr-1.m-2",       "kg∕s³");
    roundtrip(f, "W.m-1.sr-1",       "W∕m");
    roundtrip(f, "W.m-3.sr-1",       "W∕m³");
    roundtrip(f, "m3.s-1.m-1",       "m²∕s");
    roundtrip(f, "(kg.m-3)*(m.s-1)", "kg∕(m²⋅s)");
    roundtrip(f, "W.m-2.nm-1",       "10⁹⋅kg∕(m⋅s³)");
}
 
Example 7
Source File: MLAnaysisModeExpansionTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testContaining()
{
    Locale locale = Locale.UK;
    HashSet<Locale> locales = new HashSet<Locale>();
    locales.addAll(MLAnalysisMode.getLocales(MLAnalysisMode.LOCALE_AND_ALL_CONTAINING_LOCALES, locale, false));
    assertEquals(2, locales.size());
    assertTrue(locales.contains(new Locale("en", "", "")));
    assertTrue(locales.contains(new Locale("en", "GB", "")));
}
 
Example 8
Source File: TestTextParser.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="parseDayOfWeekText")
Object[][] providerDayOfWeekData() {
    return new Object[][] {
        // Locale, pattern, input text, expected DayOfWeek
        {Locale.US, "e",  "1",  DayOfWeek.SUNDAY},
        {Locale.US, "ee", "01", DayOfWeek.SUNDAY},
        {Locale.US, "c",  "1",  DayOfWeek.SUNDAY},

        {Locale.UK, "e",  "1",  DayOfWeek.MONDAY},
        {Locale.UK, "ee", "01", DayOfWeek.MONDAY},
        {Locale.UK, "c",  "1",  DayOfWeek.MONDAY},
    };
}
 
Example 9
Source File: TestTextPrinter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="print_DayOfWeekData")
Object[][] providerDayOfWeekData() {
    return new Object[][] {
        // Locale, pattern, expected text, input DayOfWeek
        {Locale.US, "e",  "1",  DayOfWeek.SUNDAY},
        {Locale.US, "ee", "01", DayOfWeek.SUNDAY},
        {Locale.US, "c",  "1",  DayOfWeek.SUNDAY},

        {Locale.UK, "e",  "1",  DayOfWeek.MONDAY},
        {Locale.UK, "ee", "01", DayOfWeek.MONDAY},
        {Locale.UK, "c",  "1",  DayOfWeek.MONDAY},
    };
}
 
Example 10
Source File: TestTextPrinter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="print_DayOfWeekData")
Object[][] providerDayOfWeekData() {
    return new Object[][] {
        // Locale, pattern, expected text, input DayOfWeek
        {Locale.US, "e",  "1",  DayOfWeek.SUNDAY},
        {Locale.US, "ee", "01", DayOfWeek.SUNDAY},
        {Locale.US, "c",  "1",  DayOfWeek.SUNDAY},

        {Locale.UK, "e",  "1",  DayOfWeek.MONDAY},
        {Locale.UK, "ee", "01", DayOfWeek.MONDAY},
        {Locale.UK, "c",  "1",  DayOfWeek.MONDAY},
    };
}
 
Example 11
Source File: TestTextParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="parseDayOfWeekText")
Object[][] providerDayOfWeekData() {
    return new Object[][] {
        // Locale, pattern, input text, expected DayOfWeek
        {Locale.US, "e",  "1",  DayOfWeek.SUNDAY},
        {Locale.US, "ee", "01", DayOfWeek.SUNDAY},
        {Locale.US, "c",  "1",  DayOfWeek.SUNDAY},

        {Locale.UK, "e",  "1",  DayOfWeek.MONDAY},
        {Locale.UK, "ee", "01", DayOfWeek.MONDAY},
        {Locale.UK, "c",  "1",  DayOfWeek.MONDAY},
    };
}
 
Example 12
Source File: TestTextParserWithLocale.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="parseDayOfWeekText")
Object[][] providerDayOfWeekData() {
    return new Object[][] {
        // Locale, pattern, input text, expected DayOfWeek
        {Locale.US, "e",  "1",  DayOfWeek.SUNDAY},
        {Locale.US, "ee", "01", DayOfWeek.SUNDAY},
        {Locale.US, "c",  "1",  DayOfWeek.SUNDAY},

        {Locale.UK, "e",  "1",  DayOfWeek.MONDAY},
        {Locale.UK, "ee", "01", DayOfWeek.MONDAY},
        {Locale.UK, "c",  "1",  DayOfWeek.MONDAY},
    };
}
 
Example 13
Source File: TestTextPrinter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name="print_DayOfWeekData")
Object[][] providerDayOfWeekData() {
    return new Object[][] {
        // Locale, pattern, expected text, input DayOfWeek
        {Locale.US, "e",  "1",  DayOfWeek.SUNDAY},
        {Locale.US, "ee", "01", DayOfWeek.SUNDAY},
        {Locale.US, "c",  "1",  DayOfWeek.SUNDAY},

        {Locale.UK, "e",  "1",  DayOfWeek.MONDAY},
        {Locale.UK, "ee", "01", DayOfWeek.MONDAY},
        {Locale.UK, "c",  "1",  DayOfWeek.MONDAY},
    };
}
 
Example 14
Source File: DateAxisTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A test to reproduce bug 2201869.
 */
@Test
public void testBug2201869() {
    TimeZone tz = TimeZone.getTimeZone("GMT");
    GregorianCalendar c = new GregorianCalendar(tz, Locale.UK);
    DateAxis axis = new DateAxis("Date", tz, Locale.UK);
    SimpleDateFormat sdf = new SimpleDateFormat("d-MMM-yyyy", Locale.UK);
    sdf.setCalendar(c);
    axis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1, sdf));
    Day d1 = new Day(1, 3, 2008);
    d1.peg(c);
    Day d2 = new Day(30, 6, 2008);
    d2.peg(c);
    axis.setRange(d1.getStart(), d2.getEnd());
    BufferedImage image = new BufferedImage(200, 100,
            BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = image.createGraphics();
    Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, 200, 100);
    axis.setTickMarkPosition(DateTickMarkPosition.END);
    List ticks = axis.refreshTicks(g2, new AxisState(), area,
            RectangleEdge.BOTTOM);
    assertEquals(3, ticks.size());
    DateTick t1 = (DateTick) ticks.get(0);
    assertEquals("31-Mar-2008", t1.getText());
    DateTick t2 = (DateTick) ticks.get(1);
    assertEquals("30-Apr-2008", t2.getText());
    DateTick t3 = (DateTick) ticks.get(2);
    assertEquals("31-May-2008", t3.getText());

    // now repeat for a vertical axis
    ticks = axis.refreshTicks(g2, new AxisState(), area,
            RectangleEdge.LEFT);
    assertEquals(3, ticks.size());
    t1 = (DateTick) ticks.get(0);
    assertEquals("31-Mar-2008", t1.getText());
    t2 = (DateTick) ticks.get(1);
    assertEquals("30-Apr-2008", t2.getText());
    t3 = (DateTick) ticks.get(2);
    assertEquals("31-May-2008", t3.getText());
}
 
Example 15
Source File: MLAnaysisModeExpansionTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testAllWC()
{
    Locale locale = Locale.UK;
    HashSet<Locale> locales = new HashSet<Locale>();
    locales.addAll(MLAnalysisMode.getLocales(MLAnalysisMode.ALL_ONLY, locale, true));
    assertEquals(2, locales.size());
    assertTrue(locales.contains(new Locale("", "", "")));
    assertTrue(locales.contains(new Locale("*", "", "")));
}
 
Example 16
Source File: APIEventBeanTest.java    From NetStorageKit-Java with Apache License 2.0 5 votes vote down vote up
@Test
public void testUploadZipAsQueryParams() throws Exception {
    SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z", Locale.UK);
    Date date = sdf.parse("11 November 2013 00:00:00 GMT");
    APIEventBean action = new APIEventUpload().withMtime(date).ofSize(123L).isIndexZip(true);

    Map<String, String> result = action.asQueryParams();

    assertThat(result.size(), is(4));
    assertThat(Utils.convertMapAsQueryParams(result), is("action=upload&index-zip=1&mtime=1384128000&version=1"));
}
 
Example 17
Source File: AnalysisStackTracesResource.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
public Representation doRepresent() {
	
	/**
	 * Fetch the analysis stacktraces
	 */
	
	ArrayNode results = mapper.createArrayNode();
	ProjectRepository projectRepository = platform.getProjectRepositoryManager().getProjectRepository();
	for (ProjectError projectError : projectRepository.getErrors()) {
		ObjectNode error = mapper.createObjectNode();
		error.put("projectId", projectError.getDbObject().get("projectId").toString());
		error.put("projectName", projectError.getDbObject().get("projectName").toString());
		error.put("clazz", projectError.getDbObject().get("clazz").toString());
		error.put("stackTrace", projectError.getDbObject().get("stackTrace").toString().replaceAll("\n", "").replaceAll("\t", ""));
		error.put("workerIdentifier", projectError.getDbObject().get("workerIdentifier").toString());
		try {
			SimpleDateFormat formater = new SimpleDateFormat("dd/MM/yyyy");
			SimpleDateFormat parser1 = new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy",Locale.UK);
			String executionDateError = projectError.getDbObject().get("date").toString();
			error.put("executionErrorDate", formater.format(parser1.parse(executionDateError)));
			
			SimpleDateFormat parser2 = new SimpleDateFormat("yyyyMMdd");
			String analysisDateError = projectError.getDbObject().get("dateForError").toString();
			error.put("analysisRangeErrorDate", formater.format(parser2.parse(analysisDateError)));
		} catch (ParseException e) {
			e.printStackTrace();
		}			
		results.add(error);
	}
	
	return Util.createJsonRepresentation(results);
}
 
Example 18
Source File: DateAxisTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A test to reproduce bug 2201869.
 */
@Test
public void testBug2201869() {
    TimeZone tz = TimeZone.getTimeZone("GMT");
    GregorianCalendar c = new GregorianCalendar(tz, Locale.UK);
    DateAxis axis = new DateAxis("Date", tz, Locale.UK);
    SimpleDateFormat sdf = new SimpleDateFormat("d-MMM-yyyy", Locale.UK);
    sdf.setCalendar(c);
    axis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1, sdf));
    Day d1 = new Day(1, 3, 2008);
    d1.peg(c);
    Day d2 = new Day(30, 6, 2008);
    d2.peg(c);
    axis.setRange(d1.getStart(), d2.getEnd());
    BufferedImage image = new BufferedImage(200, 100,
            BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = image.createGraphics();
    Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, 200, 100);
    axis.setTickMarkPosition(DateTickMarkPosition.END);
    List ticks = axis.refreshTicks(g2, new AxisState(), area,
            RectangleEdge.BOTTOM);
    assertEquals(3, ticks.size());
    DateTick t1 = (DateTick) ticks.get(0);
    assertEquals("31-Mar-2008", t1.getText());
    DateTick t2 = (DateTick) ticks.get(1);
    assertEquals("30-Apr-2008", t2.getText());
    DateTick t3 = (DateTick) ticks.get(2);
    assertEquals("31-May-2008", t3.getText());

    // now repeat for a vertical axis
    ticks = axis.refreshTicks(g2, new AxisState(), area,
            RectangleEdge.LEFT);
    assertEquals(3, ticks.size());
    t1 = (DateTick) ticks.get(0);
    assertEquals("31-Mar-2008", t1.getText());
    t2 = (DateTick) ticks.get(1);
    assertEquals("30-Apr-2008", t2.getText());
    t3 = (DateTick) ticks.get(2);
    assertEquals("31-May-2008", t3.getText());
}
 
Example 19
Source File: DateUtil.java    From ZTuoExchange_framework with MIT License 4 votes vote down vote up
public static String toGMTString(Date date) {
    SimpleDateFormat df = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z", Locale.UK);
    df.setTimeZone(new java.util.SimpleTimeZone(0, "GMT"));
    return df.format(date);
}
 
Example 20
Source File: MonthDateFormat.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Some test code.
 * 
 * @param args  ignored.
 */
public static void main(String[] args) {
    MonthDateFormat mdf = new MonthDateFormat(Locale.UK, 2);
    System.out.println("UK:");
    System.out.println(mdf.format(new Month(1, 2005).getStart()));      
    System.out.println(mdf.format(new Month(2, 2005).getStart()));      
    System.out.println(mdf.format(new Month(3, 2005).getStart()));      
    System.out.println(mdf.format(new Month(4, 2005).getStart()));      
    System.out.println(mdf.format(new Month(5, 2005).getStart()));      
    System.out.println(mdf.format(new Month(6, 2005).getStart()));      
    System.out.println(mdf.format(new Month(7, 2005).getStart()));      
    System.out.println(mdf.format(new Month(8, 2005).getStart()));      
    System.out.println(mdf.format(new Month(9, 2005).getStart()));      
    System.out.println(mdf.format(new Month(10, 2005).getStart()));     
    System.out.println(mdf.format(new Month(11, 2005).getStart()));     
    System.out.println(mdf.format(new Month(12, 2005).getStart()));  
    System.out.println();

    mdf = new MonthDateFormat(Locale.GERMANY, 2);
    System.out.println("GERMANY:");
    System.out.println(mdf.format(new Month(1, 2005).getStart()));      
    System.out.println(mdf.format(new Month(2, 2005).getStart()));      
    System.out.println(mdf.format(new Month(3, 2005).getStart()));      
    System.out.println(mdf.format(new Month(4, 2005).getStart()));      
    System.out.println(mdf.format(new Month(5, 2005).getStart()));      
    System.out.println(mdf.format(new Month(6, 2005).getStart()));      
    System.out.println(mdf.format(new Month(7, 2005).getStart()));      
    System.out.println(mdf.format(new Month(8, 2005).getStart()));      
    System.out.println(mdf.format(new Month(9, 2005).getStart()));      
    System.out.println(mdf.format(new Month(10, 2005).getStart()));     
    System.out.println(mdf.format(new Month(11, 2005).getStart()));     
    System.out.println(mdf.format(new Month(12, 2005).getStart()));  
    System.out.println();
    
    mdf = new MonthDateFormat(Locale.FRANCE, 2);
    System.out.println("FRANCE:");
    System.out.println(mdf.format(new Month(1, 2005).getStart()));      
    System.out.println(mdf.format(new Month(2, 2005).getStart()));      
    System.out.println(mdf.format(new Month(3, 2005).getStart()));      
    System.out.println(mdf.format(new Month(4, 2005).getStart()));      
    System.out.println(mdf.format(new Month(5, 2005).getStart()));      
    System.out.println(mdf.format(new Month(6, 2005).getStart()));      
    System.out.println(mdf.format(new Month(7, 2005).getStart()));      
    System.out.println(mdf.format(new Month(8, 2005).getStart()));      
    System.out.println(mdf.format(new Month(9, 2005).getStart()));      
    System.out.println(mdf.format(new Month(10, 2005).getStart()));     
    System.out.println(mdf.format(new Month(11, 2005).getStart()));     
    System.out.println(mdf.format(new Month(12, 2005).getStart()));  
    System.out.println();
    
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
    sdf.setNumberFormat(null);
    System.out.println(sdf.equals("X"));
}