Example usage for java.util Locale UK

List of usage examples for java.util Locale UK

Introduction

In this page you can find the example usage for java.util Locale UK.

Prototype

Locale UK

To view the source code for java.util Locale UK.

Click Source Link

Document

Useful constant for country.

Usage

From source file:nl.imvertor.common.Configurator.java

/**
 * Get the current date in the specified format.
 * //  www.  jav a2 s.  c  om
 * @param format
 * @return
 */
public String getCurrentDate(String format) {
    DateFormat df = new SimpleDateFormat(format, Locale.UK);
    return df.format(System.currentTimeMillis());
}

From source file:mitm.common.security.certificate.GenerateTestCertificates.java

/**
 * Generates a valid certificate/* w w  w .j a  va2s.  c om*/
 * 
 * @throws Exception
 */
private void generateValidCertificateUppercaseEmail() throws Exception {
    X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder();

    String encodedPrivateKey = "30820278020100300d06092a864886f70d0101010500048202623082025e"
            + "02010002818100cc65b29afd51609fb23b4968518b54fe26f41519dfad63"
            + "1e1a5e240bbd57c133bcbf98572f533263294a31ba77b1f56abeeff2ce5e"
            + "02f0d1c07d23464a096e06ea8d643f7205b7002f9a6ba370493b27217cd0"
            + "e5e0577cf305557cdbe7c6602badba2ae297493e75f165d2d2340fad59b7"
            + "ee0d7c05b231379aad7854c873f703020301000102818100a90547e6a6a7"
            + "8e91405f8a5a7b640e8a8447bed340862eba8bef613b5bfd9f445b46cc80"
            + "fc1f7e4145b996d9ad75398e660a21ecc90d017b5203a911ccd373694628"
            + "11f5ef0e96152fa85a1e38901ef41ee675c4de1c7ce2ed2e2af84bb8f91b"
            + "9936f699071b24e58cf44746547fee72a7d869333267dbf17fa3ac4316c2"
            + "6b91024100ed1d02ad8294c88c6e1dd376080e2265b0b872c8913ec7d735"
            + "a07be89c5432b37417265e75e388122edb4d430adc116d745824e599f8c9"
            + "9e96a5ee09e8beaf7d024100dcad92821ff13e18942db08ca02d74ecb86a"
            + "1a48c9807be5a86197361851c259c89cfb46c78f51c52558230bfe0b437b"
            + "513908c6f6d0bd0b57a74edaba0b087f02410085ed81eab13c0a7ecf5fc7"
            + "65feacc51efd0f61be09d4151a68aee9edfc06ced06fbcf7ae1916587034"
            + "c927bdbb6f8be46ff7ad77865d70bc43c91b47bb8fa11d024100bfe28594"
            + "7465f692b4b60de0199fad1df1350169ed1cb59efa8cf148ee5899602c9a"
            + "a3bbe5e66f39b7c12da84ddc496f3f2f12bcbefcbe84d05100b61c335fcd"
            + "0240403c12a1c4e1536a877631b36a075bad052b8f94580b50617fe656a8"
            + "7b45d2ada4358483fea964b25500ab2579395bafe79fd315af79fe7706c9" + "1378aab9b2be";

    String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d0030818902818100cc"
            + "65b29afd51609fb23b4968518b54fe26f41519dfad631e1a5e240bbd57c1"
            + "33bcbf98572f533263294a31ba77b1f56abeeff2ce5e02f0d1c07d23464a"
            + "096e06ea8d643f7205b7002f9a6ba370493b27217cd0e5e0577cf305557c"
            + "dbe7c6602badba2ae297493e75f165d2d2340fad59b7ee0d7c05b231379a" + "ad7854c873f7030203010001";

    PrivateKey privateKey = decodePrivateKey(encodedPrivateKey);
    PublicKey publicKey = decodePublicKey(encodedPublicKey);

    X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder();

    String email = "TEST@EXAMPLE.COM";

    subjectBuilder.setCommonName("Valid certificate uppercase email");
    subjectBuilder.setEmail(email);
    subjectBuilder.setCountryCode("NL");
    subjectBuilder.setLocality("Amsterdam");
    subjectBuilder.setState("NH");

    AltNamesBuilder altNamesBuider = new AltNamesBuilder();
    altNamesBuider.setRFC822Names(email);

    X500Principal subject = subjectBuilder.buildPrincipal();
    GeneralNames altNames = altNamesBuider.buildAltNames();

    Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>();

    keyUsage.add(KeyUsageType.DIGITALSIGNATURE);
    keyUsage.add(KeyUsageType.KEYENCIPHERMENT);
    keyUsage.add(KeyUsageType.NONREPUDIATION);

    Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>();

    extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH);
    extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION);

    BigInteger serialNumber = new BigInteger("115fcde9dc082e7e9c8eef4cc69b94c", 16);

    Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK)
            .parse("21-Nov-2007 10:39:35");

    certificateBuilder.setSubject(subject);
    certificateBuilder.setAltNames(altNames, true);
    certificateBuilder.setKeyUsage(keyUsage, true);
    certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, false);
    certificateBuilder.setNotBefore(DateUtils.addDays(now, -20));
    certificateBuilder.setNotAfter(DateUtils.addYears(now, 20));
    certificateBuilder.setPublicKey(publicKey);
    certificateBuilder.setSerialNumber(serialNumber);
    certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption");
    certificateBuilder.addSubjectKeyIdentifier(true);

    X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate);

    assertNotNull(certificate);

    certificates.add(certificate);

    Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate };

    keyStore.setKeyEntry("UppercaseEmail", privateKey, null, chain);
}

From source file:eionet.util.Util.java

/**
 *
 * @return/*from  w w  w  .  j  a v a  2 s .  c o m*/
 */
public static synchronized String getExpiresDateString() {

    if (expiresDateString == null) {
        java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",
                Locale.UK);
        dateFormat.setTimeZone(TimeZone.getTimeZone(""));
        expiresDateString = dateFormat.format(new Date(0));
    }

    return expiresDateString;
}

From source file:org.jfree.data.time.TimeSeriesTest.java

@Test
public void testFindValueRange2() {
    TimeZone tzone = TimeZone.getTimeZone("Europe/London");
    Calendar calendar = new GregorianCalendar(tzone, Locale.UK);
    calendar.clear();/*ww w .j  a va 2  s  .c o  m*/
    calendar.set(2014, Calendar.FEBRUARY, 23, 6, 0);
    long start = calendar.getTimeInMillis();
    calendar.clear();
    calendar.set(2014, Calendar.FEBRUARY, 24, 18, 0);
    long end = calendar.getTimeInMillis();
    Range range = new Range(start, end);

    TimeSeries ts = new TimeSeries("Time Series");
    assertNull(ts.findValueRange(range, TimePeriodAnchor.START, tzone));
    assertNull(ts.findValueRange(range, TimePeriodAnchor.MIDDLE, tzone));
    assertNull(ts.findValueRange(range, TimePeriodAnchor.END, tzone));

    ts.add(new Day(23, 2, 2014), 5.0);
    assertTrue(ts.findValueRange(range, TimePeriodAnchor.START, tzone).isNaNRange());
    assertEquals(new Range(5.0, 5.0), ts.findValueRange(range, TimePeriodAnchor.MIDDLE, tzone));
    assertEquals(new Range(5.0, 5.0), ts.findValueRange(range, TimePeriodAnchor.END, tzone));

    ts.add(new Day(24, 2, 2014), 6.0);
    assertEquals(new Range(6.0, 6.0), ts.findValueRange(range, TimePeriodAnchor.START, tzone));
    assertEquals(new Range(5.0, 6.0), ts.findValueRange(range, TimePeriodAnchor.MIDDLE, tzone));
    assertEquals(new Range(5.0, 5.0), ts.findValueRange(range, TimePeriodAnchor.END, tzone));

    ts.clear();
    ts.add(new Day(24, 2, 2014), null);
    assertTrue(ts.findValueRange(range, TimePeriodAnchor.START, tzone).isNaNRange());
    assertTrue(ts.findValueRange(range, TimePeriodAnchor.MIDDLE, tzone).isNaNRange());
    assertTrue(ts.findValueRange(range, TimePeriodAnchor.END, tzone).isNaNRange());
}

From source file:net.sourceforge.fenixedu.webServices.jersey.api.FenixAPIv1.java

@GET
@Produces(JSON_UTF8)/*from w  ww  .  j  a  va 2s  . co m*/
@Path("contacts")
@FenixAPIPublic
public String contacts() {
    Locale locale = I18N.getLocale();
    String contactsFile = getFileInfo("/api/contacts.json");
    JsonParser parser = new JsonParser();
    JsonObject jObj = (JsonObject) parser.parse(contactsFile);

    if (Locale.UK.equals(locale)) {
        return jObj.get(locale.toLanguageTag()).toString();
    } else {
        return jObj.get("pt-PT").toString();
    }
}

From source file:mitm.common.security.certificate.GenerateTestCertificates.java

/**
 * Generate a certificate without an email but with S/MIME extended key usage
 * //from w  w w .j ava 2 s  . c  om
 * @throws Exception
 */
private void generateCertificateNoEmail() throws Exception {
    X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder();

    String encodedPrivateKey = "30820277020100300d06092a864886f70d0101010500048202613082025d"
            + "0201000281810086246af6ba05ff48133e66771615a3e70742ff52d60db8"
            + "a4d808e73369d0c689fc21a2691ee7297311ad840fb7be841d813991f84e"
            + "9590f20a6e4d284d4d3775e646d7aed3a7142159281c9d0171bb98c1a659"
            + "b930f1e158df079136804d89864c0484e4f15482fa4c3b64c3ac58091dc4"
            + "83766b0283c2bd7c8ad12aa19c3b45020301000102818018291f0ae95e83"
            + "285c2ef50da5f0a7e0c8b20c82c3031daab32e8755ff4d17356b3033ac73"
            + "60775abe685e4ce66f6e24524e28386d0f0b584d00a8ed055f4f09ad206d"
            + "22f72a9b8b7724a43b42f0239c44e9db007652d1abf59e9d51731fda6153"
            + "3dd996c06af7761326ac57645be68f3ccc8a665aca9efc37d781c058e98f"
            + "51024100e294e1a1ddc5dbb20d09ef2113a1ddd864c444191c1b51917b69"
            + "fb9718fe6adb5bd29e9603c63d189ee79e194fa9c1484f9a5792f9a29b49"
            + "44f5efc403cd4fbb024100978f09d7c6a74c9a446510f203996b253df437"
            + "94c66e76209570ee5de5c33ee9cc09b75d06543d5b8127b7c9511253bcbf"
            + "2c74c0270c24ca36494954b02870ff024050a19eb1d594059c951b45e7c5"
            + "6ec2ddb0ee4f358855086ff7353dfd053df494df56526d1c26bdb3374941"
            + "6fcc73a27eb3253fa8e40143b58d3edff6274c36e502410088b05dfd38d2"
            + "3c5949e428f34ce1ba6bbd439c3956f9db1a2a0dcf3dea723c349a6c0cef"
            + "1e3d2d957097c4bf119a48e18b3dea123f65496d02a6f8372425653b0241"
            + "00bf58e07f459aa53487e6fb3b40caf2055e181c8505d2deb29cffffbde3"
            + "aeb5ccd0f2c353b47fe53cd3b488be85acaf55956a678ff6e37cca327f1b" + "b82044be77";

    String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d003081890281810086"
            + "246af6ba05ff48133e66771615a3e70742ff52d60db8a4d808e73369d0c6"
            + "89fc21a2691ee7297311ad840fb7be841d813991f84e9590f20a6e4d284d"
            + "4d3775e646d7aed3a7142159281c9d0171bb98c1a659b930f1e158df0791"
            + "36804d89864c0484e4f15482fa4c3b64c3ac58091dc483766b0283c2bd7c" + "8ad12aa19c3b450203010001";

    PrivateKey privateKey = decodePrivateKey(encodedPrivateKey);
    PublicKey publicKey = decodePublicKey(encodedPublicKey);

    X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder();

    subjectBuilder.setCommonName("No email");
    subjectBuilder.setCountryCode("NL");
    subjectBuilder.setLocality("Amsterdam");
    subjectBuilder.setState("NH");

    X500Principal subject = subjectBuilder.buildPrincipal();

    Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>();

    keyUsage.add(KeyUsageType.DIGITALSIGNATURE);
    keyUsage.add(KeyUsageType.KEYENCIPHERMENT);
    keyUsage.add(KeyUsageType.NONREPUDIATION);

    Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>();

    extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH);
    extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION);

    BigInteger serialNumber = new BigInteger("115fce43c64c3a7547678e8f0b67559", 16);

    Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK)
            .parse("21-Nov-2007 11:39:35");

    certificateBuilder.setSubject(subject);
    certificateBuilder.setKeyUsage(keyUsage, true);
    certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, false);
    certificateBuilder.setNotBefore(DateUtils.addDays(now, -20));
    certificateBuilder.setNotAfter(DateUtils.addYears(now, 20));
    certificateBuilder.setPublicKey(publicKey);
    certificateBuilder.setSerialNumber(serialNumber);
    certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption");
    certificateBuilder.addSubjectKeyIdentifier(true);

    X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate);

    assertNotNull(certificate);

    certificates.add(certificate);

    Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate };

    keyStore.setKeyEntry("noEmail", privateKey, null, chain);
}

From source file:mitm.common.security.certificate.GenerateTestCertificates.java

/**
 * Generate a certificate with email in subject but not in AltNames
 * /*from  w w  w  . j a  v  a2s .c om*/
 * @throws Exception
 */
private void generateCertificateEmailInSubjectNotInAltNames() throws Exception {
    X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder();

    String encodedPrivateKey = "30820276020100300d06092a864886f70d0101010500048202603082025c"
            + "02010002818100d101622e0d0d3edb037b595281d54029fb4d5c0bc2025f"
            + "d378f7098b6cdf3a90450978cac7b699ab1457c361384d38278f62a2a3a0"
            + "42988d7ce079170c942ee8b6cbbf2cd2f85be52bd686f4b0d344c24d6acb"
            + "47f926034bfe312353893499bcb6eb6f9aa6e8b203768c93579c93e3234c"
            + "0a345dcfa5e0a3434a205f87dc6ec50203010001028180423a7d00f8b3cc"
            + "ca1bd5575d94b49d6b702d7850657ed91caac5252a202ab0650ceb4e727b"
            + "4c7a6f42b7f8ba72dbcd4283e60e81690411512c53f92afb9a6d2e4fd74d"
            + "bc4c34b73575e60b4e656f23f730a08436fb32bd89c44f120a73757e8fde"
            + "63a12fd9e7860406604acbf006fd235573be8bfb4ffcb3e55f2785cbb009"
            + "a1024100f90a4dbd692dd5948472e5d589fe52c58f85e5ec778ab22cf965"
            + "557e6ad46e08ff8e532e800fe58643c1eae5ef8c3bf1e3f746c0e51f8f97"
            + "4bfeed4dcdd89d69024100d6d8a918fffc750e02ecd443139515ce624e68"
            + "24b808f244e0aabcf00f5323fb0dfe54ffa56b1fcd5b90f6ddff639fea7b"
            + "0843debed0088a0f7dd42cb8802efd024075b569091dad8c45a654a84d45"
            + "ebef3371a2d809ec76a1c0a02045487b35eccc53fdf15309347a47fbbeac"
            + "4801f146640e5bd2155a3690a7f2438be63a6528010240772d644fcbe03d"
            + "0672b4f0e1ec80ecc1b96288fea55fc11458141e0e8451b849d16f5db31a"
            + "0d9c6c8bf894187d4cc42e8be4ffd115c3cc98d9131199651725f9024100"
            + "c74bca53cdd2650796285a3cd9ad48f25e9308532fa3ce3f366abe2a9e5c"
            + "b55dc7a1a7c9d6d30070eeb1584505e493a39515a3e306ed8299ccfcbc02" + "32984aef";

    String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d0030818902818100d1"
            + "01622e0d0d3edb037b595281d54029fb4d5c0bc2025fd378f7098b6cdf3a"
            + "90450978cac7b699ab1457c361384d38278f62a2a3a042988d7ce079170c"
            + "942ee8b6cbbf2cd2f85be52bd686f4b0d344c24d6acb47f926034bfe3123"
            + "53893499bcb6eb6f9aa6e8b203768c93579c93e3234c0a345dcfa5e0a343" + "4a205f87dc6ec50203010001";

    PrivateKey privateKey = decodePrivateKey(encodedPrivateKey);
    PublicKey publicKey = decodePublicKey(encodedPublicKey);

    X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder();

    String email = "test@example.com";

    subjectBuilder.setCommonName("Email in Subject not in AltNames");
    subjectBuilder.setEmail(email);
    subjectBuilder.setCountryCode("NL");
    subjectBuilder.setLocality("Amsterdam");
    subjectBuilder.setState("NH");

    X500Principal subject = subjectBuilder.buildPrincipal();

    Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>();

    keyUsage.add(KeyUsageType.DIGITALSIGNATURE);
    keyUsage.add(KeyUsageType.KEYENCIPHERMENT);
    keyUsage.add(KeyUsageType.NONREPUDIATION);

    Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>();

    extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH);
    extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION);

    BigInteger serialNumber = new BigInteger("115fceb7f46b98775dbb8287965f838", 16);

    Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK)
            .parse("21-Nov-2007 11:40:35");

    certificateBuilder.setSubject(subject);
    certificateBuilder.setKeyUsage(keyUsage, true);
    certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, false);
    certificateBuilder.setNotBefore(DateUtils.addDays(now, -20));
    certificateBuilder.setNotAfter(DateUtils.addYears(now, 20));
    certificateBuilder.setPublicKey(publicKey);
    certificateBuilder.setSerialNumber(serialNumber);
    certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption");
    certificateBuilder.addSubjectKeyIdentifier(true);

    X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate);

    assertNotNull(certificate);

    certificates.add(certificate);

    Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate };

    keyStore.setKeyEntry("emailInSubjectNotInAltNames", privateKey, null, chain);
}

From source file:it.tidalwave.bluemarine2.metadata.impl.audio.musicbrainz.MusicBrainzAudioMedatataImporter.java

/*******************************************************************************************************************
 *
 *
 *
 *
 ******************************************************************************************************************/
public static int similarity(final @Nonnull String a, final @Nonnull String b) {
    int score = StringUtils.getFuzzyDistance(a.toLowerCase(), b.toLowerCase(), Locale.UK);
    ////  ww w  . j  a  v  a 2  s .c om
    // While this is a hack, it isn't so ugly as it might appear. The idea is to give a lower score to
    // collections and records with a generic title, hoping that a better one is picked.
    // FIXME: put into a map and then into an external resource with the delta score associated.
    // FIXME: with the filtering on collection size, this might be useless?
    //
    if (a.matches("^Great Violin Concertos.*") || a.matches("^CBS Great Performances.*")) {
        score -= 50;
    }

    if (a.matches("^Piano Concertos$") || a.matches("^Klavierkonzerte$")) {
        score -= 30;
    }

    return score;
}

From source file:org.openmrs.api.ConceptServiceTest.java

/**
 * This tests for being able to find concepts with names in the en locale when the user is in
 * the en_GB locale// w ww . ja v  a  2s  .  c  o  m
 * 
 * @see ConceptService#getConceptByName(String)
 */
@Test
@Verifies(value = "should find concepts with names in more generic locales", method = "getConceptByName(String)")
public void getConceptByName_shouldFindConceptsWithNamesInMoreGenericLocales() throws Exception {
    executeDataSet(INITIAL_CONCEPTS_XML);
    //prior tests have changed the locale to 'en_US', so we need to set it back
    Context.setLocale(Locale.UK);
    // make sure that concepts are found that have a specific locale on them
    Assert.assertNotNull(Context.getConceptService().getConceptByName("Some numeric concept name"));
}

From source file:org.openmrs.api.ConceptServiceTest.java

/**
 * This tests for being able to find concepts with names in en_GB locale when the user is in the
 * en_GB locale./*from  ww w.ja v  a 2 s. co  m*/
 * 
 * @see ConceptService#getConceptByName(String)
 */
@Test
@Verifies(value = "should find concepts with names in same specific locale", method = "getConceptByName(String)")
public void getConceptByName_shouldFindConceptsWithNamesInSameSpecificLocale() throws Exception {
    executeDataSet(INITIAL_CONCEPTS_XML);

    Context.setLocale(Locale.UK);

    // make sure that concepts are found that have a specific locale on them
    Assert.assertNotNull(Context.getConceptService().getConceptByName("Numeric name with en_GB locale"));
}