List of usage examples for java.util Locale UK
Locale UK
To view the source code for java.util Locale UK.
Click Source Link
From source file:org.apache.wicket.security.examples.springsecurity.AbstractSecureTestPage.java
/** * @see junit.framework.TestCase#setUp() *///from w w w. j a v a 2 s . c o m @Override protected void setUp() throws Exception { Locale.setDefault(Locale.UK); String webAppLocation; File currentDir = new File("."); log.debug("CurrentDir:" + currentDir.getCanonicalPath()); if (currentDir.getCanonicalPath().endsWith("examples/spring-security")) { webAppLocation = "src/main/webapp"; } else { webAppLocation = "examples/spring-security/src/main/webapp"; } log.debug("start the testapplication with location: " + webAppLocation); application = new SpringSecureWicketTestApplication(); mock = new WicketTester(application, webAppLocation); }
From source file:uk.q3c.krail.i18n.DefaultPatternUtilityTest.java
@Test public void writeOut_locales_provided_all_keys() throws IOException { // given File testOutDir = new File(ResourceUtils.userTempDirectory(), "testOut"); if (testOutDir.exists()) { FileUtils.deleteQuietly(testOutDir); }/*from w w w. ja v a 2 s . c o m*/ File targetDir = new File(ResourceUtils.userTempDirectory(), "testOut/codeModel"); writer.setOptionWritePath(targetDir); Set<Locale> locales = new HashSet<>(); locales.add(Locale.GERMAN); locales.add(Locale.ITALIAN); locales.add(Locale.UK); locales.add(Locale.forLanguageTag("")); File referenceFile = new File(TestResource.testResourceRootDir("krail"), "Labels.ref"); File targetFile = new File(targetDir, "Labels.java"); File referenceFile_de = new File(TestResource.testResourceRootDir("krail"), "Labels_de.ref"); File targetFile_de = new File(targetDir, "Labels_de.java"); File referenceFile_it = new File(TestResource.testResourceRootDir("krail"), "Labels_it.ref"); File targetFile_it = new File(targetDir, "Labels_it.java"); File referenceFile_en_GB = new File(TestResource.testResourceRootDir("krail"), "Labels_en_GB.ref"); File targetFile_en_GB = new File(targetDir, "Labels_en_GB.java"); // this is to make sure that setting the default does not mess things up Locale.setDefault(Locale.CANADA_FRENCH); //when utility.writeOut(writer, LabelKey.class, locales, Optional.empty()); //then line 4 is the timestamp assertThat(FileTestUtil.compare(referenceFile, targetFile, 4)).isEqualTo(Optional.empty()); assertThat(FileTestUtil.compare(referenceFile_de, targetFile_de, 4)).isEqualTo(Optional.empty()); assertThat(FileTestUtil.compare(referenceFile_it, targetFile_it, 4)).isEqualTo(Optional.empty()); assertThat(FileTestUtil.compare(referenceFile_en_GB, targetFile_en_GB, 4)).isEqualTo(Optional.empty()); }
From source file:org.atomserver.core.PhysicalStorageTest.java
public void testPhysicalStorage() throws Exception { File root = new File(System.getProperty("java.io.tmpdir"), "storage"); try {/*from w w w .j av a2 s. c om*/ TestingContentStorage fileBasedStorage = new TestingContentStorage(root); TestingContentStorage storage = fileBasedStorage; storage.setTestingFailOnGet(false); assertEquals(root, fileBasedStorage.getRootDir()); assertTrue(storage.canRead()); EntryDescriptor my_1234_en = new BaseEntryDescriptor("widgets", "mine", "1234", Locale.ENGLISH, 1); EntryDescriptor my_1234_en_GB = new BaseEntryDescriptor("widgets", "mine", "1234", Locale.UK, 0); assertFalse(storage.contentExists(my_1234_en)); storage.putContent("mine:1234:en", my_1234_en); storage.putContent("mine:1234:en", my_1234_en_GB); assertTrue(storage.contentExists(my_1234_en)); assertEquals("mine:1234:en", storage.getContent(my_1234_en)); assertTrue(storage.contentExists(my_1234_en_GB)); assertEquals("mine:1234:en", storage.getContent(my_1234_en_GB)); //assertEquals(storage.lastModified(my_1234_en), storage.lastModified(my_1234_en_GB)); Thread.sleep(1100); // sleep for just over a second, to make sure the mod times are different. storage.putContent("mine:1234:en_GB", my_1234_en_GB); assertTrue(storage.contentExists(my_1234_en)); assertEquals("mine:1234:en", storage.getContent(my_1234_en)); assertTrue(storage.contentExists(my_1234_en_GB)); assertEquals("mine:1234:en_GB", storage.getContent(my_1234_en_GB)); assertTrue(fileBasedStorage.lastModified(my_1234_en) < fileBasedStorage.lastModified(my_1234_en_GB)); File file_1234_en = (File) storage.getPhysicalRepresentation("widgets", "mine", "1234", Locale.ENGLISH, 1); File file_1234_en_GB = (File) storage.getPhysicalRepresentation("widgets", "mine", "1234", Locale.UK, 0); log.debug("PATH= " + file_1234_en.getAbsolutePath()); EntryDescriptor out_1234_en = fileBasedStorage.getEntryMetaData(file_1234_en.getAbsolutePath()); assertNotNull(out_1234_en); assertEquals(my_1234_en.getWorkspace(), out_1234_en.getWorkspace()); assertEquals(my_1234_en.getCollection(), out_1234_en.getCollection()); assertEquals(my_1234_en.getEntryId(), out_1234_en.getEntryId()); assertEquals(my_1234_en.getLocale(), out_1234_en.getLocale()); // we started at rev1, so the file should match assertEquals(1, out_1234_en.getRevision()); EntryDescriptor out_1234_en_GB = fileBasedStorage.getEntryMetaData(file_1234_en_GB.getAbsolutePath()); assertEquals(my_1234_en_GB.getWorkspace(), out_1234_en_GB.getWorkspace()); assertEquals(my_1234_en_GB.getCollection(), out_1234_en_GB.getCollection()); assertEquals(my_1234_en_GB.getEntryId(), out_1234_en_GB.getEntryId()); assertEquals(my_1234_en_GB.getLocale(), out_1234_en_GB.getLocale()); // we started at rev0, and PUT twice, so the file should match assertEquals(1, out_1234_en.getRevision()); storage.deleteContent(null, my_1234_en); assertFalse(storage.contentExists(my_1234_en)); assertEquals(null, storage.getContent(my_1234_en)); assertTrue(storage.contentExists(my_1234_en_GB)); assertEquals("mine:1234:en_GB", storage.getContent(my_1234_en_GB)); } finally { FileUtils.deleteDirectory(root); } }
From source file:com.uk_postcodes.api.Postcode.java
/** * Checks the candidate postcode against the Royal Mail approved regex * @param postcode the postcode to validate * @return true if the postcode is valid *//* w w w. j a v a 2s . c o m*/ public static boolean isValid(String postcode) { return postcodePattern.matcher(postcode.toUpperCase(Locale.UK)).matches(); }
From source file:org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils.java
/** * Parses a string with a given format and returns the Epoch time. * If no timezone information is given, the default timezone of the JVM is used * ({@link java.util.TimeZone#getDefault()}). * * @param date The string containing the date. * @param format The format of the date. * @return The date in Epoch format.//from ww w. ja v a2 s . c o m * @throws ParseException if the date cannot be parsed with the given format */ public static long getEpoch(String date, String format) throws ParseException { return new SimpleDateFormat(format, Locale.UK).parse(date).getTime(); }
From source file:org.powertac.producer.pvfarm.IrradianceModelTest.java
@Test public void testClearSkyModelCoefficients() throws IOException { File file = new File("data/dataSkyModelCoefficients.txt"); file.createNewFile();//from ww w .jav a2 s.c o m PrintWriter pw = new PrintWriter(new File("data/dataSkyModelCoefficients.txt")); for (double airmass = 1.0; airmass < 38.0; airmass += 0.2) { double Tr = IrradianceModel.getTr(airmass); double T0 = IrradianceModel.getT0(airmass, 3); double aw = IrradianceModel.getaw(airmass, 0.2, 300); assertTrue(String.valueOf(T0 * Tr - aw), T0 * Tr - aw <= 1); assertTrue(String.valueOf(T0 * Tr - aw), T0 * Tr - aw >= 0); assertTrue(String.valueOf(T0), T0 <= 1); assertTrue(String.valueOf(T0), T0 >= 0); assertTrue("Airmass: " + airmass, 1 - Tr <= 1); assertTrue("Airmass: " + airmass, 1 - Tr >= 0); pw.printf(Locale.UK, "%f,%f,%f,%f,%n", airmass, T0 * Tr - aw, T0, 1 - Tr); } for (double temperature = 280; temperature < 320; temperature++) { double Tr = IrradianceModel.getTr(1); double T0 = IrradianceModel.getT0(1, 3); double aw = IrradianceModel.getaw(1, 0.5, temperature); assertTrue(T0 * Tr - aw <= 1 && T0 * Tr - aw >= 0); } pw.close(); }
From source file:test.pl.chilldev.facelets.taglib.spring.web.MessageTagTest.java
@Test public void applyLocale() throws FacesException { String message = "Foo"; String var = "bar"; Locale locale = Locale.UK; String translated = "Baz"; Map<String, Object> config = new HashMap<>(); config.put(MessageTag.ATTRIBUTE_MESSAGE, message); config.put(MessageTag.ATTRIBUTE_LOCALE, locale); config.put(MessageTag.ATTRIBUTE_VAR, var); MessageTag tag = new MessageTag(MockTagConfig.factory(config)); // set up context FaceletContext context = new MockFaceletContext(); context.getFacesContext().getExternalContext().getApplicationMap() .put(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.applicationContext); when(this.applicationContext.getBean(MessageSource.class)).thenReturn(this.messageSource); when(this.messageSource.getMessage(message, null, locale)).thenReturn(translated); // run the tag tag.apply(context, this.parent); assertEquals("MessageTag.apply() should use specified locale.", translated, context.getAttribute(var)); }
From source file:org.opendatakit.common.android.utilities.ODKDataUtilsTest.java
@Test public void testNormalizeDisplayName() throws JsonProcessingException { Map<String, Object> langMap = new TreeMap<String, Object>(); langMap.put("en_US", "This is a test"); langMap.put("en_GB", "Test is This"); langMap.put("en", "Huh Test"); langMap.put("fr", "Je suis"); langMap.put("default", "No way!"); String value = ODKFileUtils.mapper.writeValueAsString(langMap); String match;/* w w w . j ava 2 s . c om*/ Locale.setDefault(Locale.US); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("This is a test", match); Locale.setDefault(Locale.UK); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("Test is This", match); Locale.setDefault(Locale.CANADA); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("Huh Test", match); Locale.setDefault(Locale.CANADA_FRENCH); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("Je suis", match); Locale.setDefault(Locale.GERMANY); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("No way!", match); Locale.setDefault(Locale.US); }
From source file:org.jfree.chart.demo.StackedXYAreaChartDemo.java
/** * Creates a new demo.//from www . j a va2 s. c o m * * @param title the frame title. */ public StackedXYAreaChartDemo(final String title) { super(title); final SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.UK); final XYSeries series1 = new XYSeries("Series 1", true, false); final XYSeries series2 = new XYSeries("Series 2", true, false); final XYSeries series3 = new XYSeries("Series 3", true, false); try { series1.add(sdf.parse("03-Jul-2003").getTime(), 115); series1.add(sdf.parse("04-Jul-2003").getTime(), 120); series1.add(sdf.parse("07-Jul-2003").getTime(), 125); series1.add(sdf.parse("08-Jul-2003").getTime(), 160); series1.add(sdf.parse("09-Jul-2003").getTime(), 175); series1.add(sdf.parse("10-Jul-2003").getTime(), 140); series1.add(sdf.parse("11-Jul-2003").getTime(), 145); series1.add(sdf.parse("14-Jul-2003").getTime(), 150); series1.add(sdf.parse("15-Jul-2003").getTime(), 155); series1.add(sdf.parse("16-Jul-2003").getTime(), 160); series1.add(sdf.parse("17-Jul-2003").getTime(), 165); series1.add(sdf.parse("18-Jul-2003").getTime(), 170); series2.add(sdf.parse("30-Jun-2003").getTime(), 50); series2.add(sdf.parse("01-Jul-2003").getTime(), 60); series2.add(sdf.parse("02-Jul-2003").getTime(), 70); series2.add(sdf.parse("03-Jul-2003").getTime(), 80); series2.add(sdf.parse("04-Jul-2003").getTime(), 90); series2.add(sdf.parse("07-Jul-2003").getTime(), 100); series2.add(sdf.parse("08-Jul-2003").getTime(), 110); series2.add(sdf.parse("09-Jul-2003").getTime(), 120); series2.add(sdf.parse("10-Jul-2003").getTime(), 130); series2.add(sdf.parse("11-Jul-2003").getTime(), 140); series2.add(sdf.parse("14-Jul-2003").getTime(), 150); series2.add(sdf.parse("15-Jul-2003").getTime(), 160); series2.add(sdf.parse("16-Jul-2003").getTime(), 170); series2.add(sdf.parse("17-Jul-2003").getTime(), 180); series2.add(sdf.parse("18-Jul-2003").getTime(), 190); series3.add(sdf.parse("30-Jun-2003").getTime(), 100); series3.add(sdf.parse("01-Jul-2003").getTime(), 120); series3.add(sdf.parse("02-Jul-2003").getTime(), 110); series3.add(sdf.parse("03-Jul-2003").getTime(), 120); series3.add(sdf.parse("04-Jul-2003").getTime(), 130); series3.add(sdf.parse("07-Jul-2003").getTime(), 135); series3.add(sdf.parse("08-Jul-2003").getTime(), 140); series3.add(sdf.parse("09-Jul-2003").getTime(), 155); series3.add(sdf.parse("10-Jul-2003").getTime(), 130); series3.add(sdf.parse("11-Jul-2003").getTime(), 135); series3.add(sdf.parse("14-Jul-2003").getTime(), 140); series3.add(sdf.parse("15-Jul-2003").getTime(), 165); series3.add(sdf.parse("16-Jul-2003").getTime(), 170); series3.add(sdf.parse("17-Jul-2003").getTime(), 165); series3.add(sdf.parse("18-Jul-2003").getTime(), 140); } catch (ParseException e) { // Not likely, given that the dates are hard-coded e.printStackTrace(); } final DefaultTableXYDataset dataset = new DefaultTableXYDataset(); dataset.addSeries(series1); dataset.addSeries(series2); dataset.addSeries(series3); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:net.networksaremadeofstring.cyllell.Authentication.java
private String GetTimeStamp() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.UK); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); return sdf.format(new Date()); }