Java Code Examples for java.util.Locale#UK

The following examples show how to use java.util.Locale#UK . These examples are extracted from open source projects. 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
/**
 * 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 2
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 3
/**
 * 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 4
Source Project: sis   File: UnitFormatTest.java    License: 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 5
Source Project: SIMVA-SoS   File: PeriodAxisTest.java    License: 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
/**
 * 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 7
/**
 * 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 8
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 9
@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 10
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 11
/**
 * 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 12
@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 13
@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 14
@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 15
@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 16
@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 17
@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 18
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 19
/**
 * 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"));
}
 
Example 20
Source Project: ZTuoExchange_framework   File: DateUtil.java    License: 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);
}