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:org.jfree.data.time.MinuteTest.java

/**
 * Some checks for the getFirstMillisecond() method.
 *///from w  ww.  j  a  va 2s .  c o m
@Test
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Minute m = new Minute(43, 15, 1, 4, 2006);
    assertEquals(1143902580000L, m.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}

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

/**
 * Some checks for the getFirstMillisecond() method.
 *///  w w  w . ja  v  a2s.  c  om
@Test
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Second s = new Second(15, 43, 15, 1, 4, 2006);
    assertEquals(1143902595000L, s.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}

From source file:org.duniter.client.Main.java

protected void initI18n() throws IOException {
    Configuration config = Configuration.instance();

    // --------------------------------------------------------------------//
    // init i18n/*from w ww  .  j  ava  2 s.  com*/
    // --------------------------------------------------------------------//
    File i18nDirectory = config.getI18nDirectory();
    if (i18nDirectory.exists()) {
        // clean i18n cache
        FileUtils.cleanDirectory(i18nDirectory);
    }

    FileUtils.forceMkdir(i18nDirectory);

    if (debug) {
        System.out.println("INFO - I18N directory: " + i18nDirectory);
    }

    Locale i18nLocale = config.getI18nLocale();

    // Fix locale
    if (i18nLocale.equals(Locale.FRENCH)) {
        i18nLocale = Locale.FRANCE;
    } else if (i18nLocale.equals(Locale.ENGLISH)) {
        i18nLocale = Locale.UK;
    }

    if (debug) {
        System.out.println(
                String.format("INFO - Starts i18n with locale [%s] at [%s]", i18nLocale, i18nDirectory));
    }
    I18n.init(new UserI18nInitializer(i18nDirectory, new DefaultI18nInitializer(getI18nBundleName())),
            i18nLocale);
}

From source file:uk.ac.abdn.fits.support.thymeleaf.springmail.web.MailController.java

@RequestMapping(value = "/sendMailSimple", method = RequestMethod.POST)
public @ResponseBody RESTFulRequest sendSimpleMail(HttpSession session, HttpServletRequest request,
        //          HttpServletResponse response,
        Model model, final Locale locale) throws MessagingException {

    String recipientName = "Cheng Zeng";
    String recipientEmail = "c.zeng@abdn.ac.uk";
    String fname = (String) session.getAttribute("fname");
    String lname = (String) session.getAttribute("lname");
    String email = (String) session.getAttribute("email");
    if (fname != null && lname != null) {
        recipientName = fname + " " + lname;
        System.out.println("recipientName: " + recipientName);
    }/* ww w . j  av  a2  s .c  o  m*/
    if (email != null && !email.equals("")) {
        recipientEmail = email;
        System.out.println("recipientEmail: " + recipientEmail);
    }

    List<TOption> not_relaxed = (List<TOption>) session.getAttribute("options");
    List<TOption> relaxed_options = (List<TOption>) session.getAttribute("relaxed_options");
    String date_of_travel = (String) session.getAttribute("date_of_travel");
    String origin_postcode = (String) session.getAttribute("origin_postcode");

    List<TOption> not_relaxed_rtn = (List<TOption>) session.getAttribute("options_rtn");
    List<TOption> relaxed_options_rtn = (List<TOption>) session.getAttribute("relaxed_options_rtn");
    String origin_postcode_rtn = (String) session.getAttribute("origin_postcode_rtn");

    String url = null;
    View resolvedView;
    try {
        model.addAttribute("date_of_travel", date_of_travel);
        model.addAttribute("origin_postcode", origin_postcode);
        model.addAttribute("options", not_relaxed);
        model.addAttribute("relaxed_options", relaxed_options);
        model.addAttribute("caption", "Transport options ranked using preferences");
        model.addAttribute("origin_postcode_rtn", origin_postcode_rtn);
        model.addAttribute("options_rtn", not_relaxed_rtn);
        model.addAttribute("relaxed_options_rtn", relaxed_options_rtn);
        model.addAttribute("email_view", "email_view");
        resolvedView = this.viewResolver.resolveViewName("matching", Locale.UK);
        MockHttpServletResponse mockResp = new MockHttpServletResponse();
        resolvedView.render(model.asMap(), request, mockResp);
        //          System.out.println("rendered html : " + mockResp.getContentAsString());
        url = saveAsHtml(request, mockResp.getContentAsString());
        emailService.sendRichMail(recipientName, recipientEmail, locale, url);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return new RESTFulRequest(1, "mail sent to " + recipientEmail);
}

From source file:com.domingosuarez.boot.autoconfigure.jade4j.Jade4JAutoConfigurationTests.java

@Test
public void createLayoutFromConfigClass() throws Exception {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(Jade4JAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    MockServletContext servletContext = new MockServletContext();
    context.setServletContext(servletContext);
    context.refresh();/*from www  . j av a 2  s. c  o  m*/

    JadeView view = (JadeView) context.getBean(JadeViewResolver.class).resolveViewName("demo", Locale.UK);
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
    view.render(params(), request, response);
    String result = response.getContentAsString();
    assertTrue("Wrong result: " + result, result.contains("<title>Jade</title>"));
    assertTrue("Wrong result: " + result, result.contains("<h2>With user</h2>"));
    context.close();
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.EncounterProviderResource1_9Test.java

@Test
public void testAddingDuplicateDoesNotCreateNewRecord() throws Exception {
    // If we don't explicitly set a locale, then a Context.getLocale() call nested somewhere below will trigger a
    // premature hibernate flush because it looks up the global property for default locale
    Context.setLocale(Locale.UK);

    // now add a provider *with the same provider and role* as the existing one
    Encounter encounter = encounterService.getEncounter(3);
    EncounterProviderResource1_9 resource = getResource();
    SimpleObject post = new SimpleObject().add("provider", EXISTING_ENCOUNTER_PROVIDER_PROVIDER_UUID)
            .add("encounterRole", EXISTING_ENCOUNTER_PROVIDER_ENCOUNTER_ROLE_UUID);
    Object created = resource.create(encounter.getUuid(), post, new RequestContext());

    // should return uuid of *existing* encounter provider
    assertThat((String) getByPath(created, "uuid"), is(EXISTING_ENCOUNTER_PROVIDER_UUID));
    Context.flushSession();// www .  j a v  a  2  s.c o  m

    // there should still only be one provider
    assertThat(getEncounterProviderCountWithoutFlushing(), is(1));
}

From source file:it.polimi.diceH2020.SPACE4CloudWS.solvers.solversImpl.MINLPSolver.MINLPDataFileBuilder.java

<N extends Number> MINLPDataFileBuilder addArrayParameter(String name, Iterable<N> values) {
    String currentLine = String.format("param: %s :=", name);
    lines.add(currentLine);/*from w  w  w .  j  av a  2 s.  c  o  m*/
    int idx = 1;
    for (N value : values) {
        if (value instanceof Double) {
            //UK to have . instead of , as separator
            currentLine = String.format(Locale.UK, "%d %f", idx++, value.doubleValue());
        } else if (value instanceof Integer) {
            currentLine = String.format("%d %d", idx++, value.intValue());
        }
        lines.add(currentLine);
    }
    lines.add(";");
    return this;
}

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

/**
 * Some checks for the getFirstMillisecond() method.
 *///from   ww w.  j  a  v  a2s  . c  o m
@Test
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Millisecond m = new Millisecond(500, 15, 43, 15, 1, 4, 2006);
    assertEquals(1143902595500L, m.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}

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

/**
 * The first week in 2005 should span the range:
 *
 * TimeZone         | Start Millis  | End Millis    | Start Date  | End Date
 * -----------------+---------------+---------------+-------------+------------
 * Europe/London    | 1104710400000 | 1105315199999 |  3-Jan-2005 | 9-Jan-2005
 * Europe/Paris     | 1104706800000 | 1105311599999 |  3-Jan-2005 | 2-Jan-2005
 * America/New_York | 1104037200000 | 1104641999999 | 26-Dec-2004 | 1-Jan-2005
 *
 * In London and Paris, Monday is the first day of the week, while in the
 * US it is Sunday./*from  w ww .  ja v  a 2  s. c  om*/
 *
 * Previously, we were using these values, but see Java Bug ID 4960215:
 *
 * TimeZone         | Start Millis  | End Millis    | Start Date  | End Date
 * -----------------+---------------+---------------+-------------+------------
 * Europe/London    | 1104105600000 | 1104710399999 | 27-Dec-2004 | 2-Jan-2005
 * Europe/Paris     | 1104102000000 | 1104706799999 | 27-Dec-2004 | 2-Jan-2005
 * America/New_York | 1104037200000 | 1104641999999 | 26-Dec-2004 | 1-Jan-2005
 */
@Test
public void testWeek12005() {
    Week w1 = new Week(1, 2005);
    Calendar c1 = Calendar.getInstance(TimeZone.getTimeZone("Europe/London"), Locale.UK);
    c1.setMinimalDaysInFirstWeek(4); // see Java Bug ID 4960215
    assertEquals(1104710400000L, w1.getFirstMillisecond(c1));
    assertEquals(1105315199999L, w1.getLastMillisecond(c1));
    Calendar c2 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Paris"), Locale.FRANCE);
    c2.setMinimalDaysInFirstWeek(4); // see Java Bug ID 4960215
    assertEquals(1104706800000L, w1.getFirstMillisecond(c2));
    assertEquals(1105311599999L, w1.getLastMillisecond(c2));
    Calendar c3 = Calendar.getInstance(TimeZone.getTimeZone("America/New_York"), Locale.US);
    assertEquals(1104037200000L, w1.getFirstMillisecond(c3));
    assertEquals(1104641999999L, w1.getLastMillisecond(c3));
}

From source file:org.jfree.data.time.junit.MinuteTest.java

/**
 * Some checks for the getFirstMillisecond() method.
 *//*from  ww w  . j  av  a2 s  .  c  o m*/
public void testGetFirstMillisecond() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Minute m = new Minute(43, 15, 1, 4, 2006);
    assertEquals(1143902580000L, m.getFirstMillisecond());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}