Example usage for java.util Locale CANADA

List of usage examples for java.util Locale CANADA

Introduction

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

Prototype

Locale CANADA

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

Click Source Link

Document

Useful constant for country.

Usage

From source file:com.github.tuxychandru.spring.mustache.MustacheViewResolverTest.java

@Test
public void testResolution() throws Exception {
    MustacheViewResolver resolver = new MustacheViewResolver();
    resolver.setApplicationContext(mockContext);
    resolver.setPrefix("views/");
    resolver.setSuffix(".html");

    MustacheView view = (MustacheView) resolver.resolveViewName("abc", Locale.CANADA);
    assertEquals("views/abc.html", view.getUrl());
}

From source file:com.isalnikov.config.MessageTest.java

@Test(expected = IllegalStateException.class)
public void testNull() {
    System.out.println(messageHelper.getMessage(Locale.CANADA, null));
    System.out.println(messageHelper.getMessage(""));
    System.out.println(messageHelper.getMessage(new Object[] {}));
    System.out.println(messageHelper.getMessage(new Object[] { "" }));
}

From source file:org.web4thejob.orm.ListSerializationTest.java

@Test
public void localesListTest() throws IOException {
    final Marshaller marshaller = ContextUtil.getBean(Marshaller.class);
    Assert.assertNotNull(marshaller);//from   w w w  .j a  v  a2 s  .c  o  m

    List<Locale> locales = new ArrayList<Locale>();
    locales.add(Locale.CANADA);
    locales.add(Locale.CHINA);
    locales.add(Locale.ENGLISH);

    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final Result result = new StreamResult(out);
    marshaller.marshal(locales, result);
    System.out.println(out.toString("UTF-8"));

}

From source file:info.pancancer.arch3.reportcli.ReportCLI.java

public void doWork() throws Exception {

    final HierarchicalINIConfiguration settings = Utilities.parseConfig(configFile);
    final PostgreSQL db = new PostgreSQL(settings);

    ReportAPI reportAPI = ReportAPIFactory.makeReportAPI(settings, db);
    // later, we'll replace his with a proper CLI renderer
    SlackRenderer renderer = new SlackRenderer(reportAPI);
    List<?> nonOptionArguments = options.nonOptionArguments();
    String joined = Joiner.on("").join(nonOptionArguments).toUpperCase(Locale.CANADA);
    SlackRenderer.FormattedMessage result = renderer.convertToResult(joined);
    if (result.message != null) {
        System.out.print(renderer.convertToResult(joined).message);
    }/*  w w  w .  ja v  a2s.  c  o  m*/
    if (result.attachment != null) {
        System.out.print(renderer.convertToResult(joined).attachment.toString());
    }
}

From source file:com.isalnikov.config.MessageTest.java

@Test
public void testHelloConfigurer() {
    System.out.println(messageHelper.getMessage("hello"));
    System.out.println(messageHelper.getMessage(Locale.CANADA, "hello"));
    System.out.println(messageHelper.getMessage(Locale.ENGLISH, "hello"));
    System.out.println(messageHelper.getMessage(new Locale("ru"), "hello"));
    System.out.println(messageHelper.getMessage(new Locale("ru_RU"), "hello"));
}

From source file:com.example.michael.paradis2_habittracker.CreateNewHabit.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Date habitdate = new Date();
    super.onCreate(savedInstanceState);
    SimpleDateFormat formats = new SimpleDateFormat("yyyy-MM-dd", Locale.CANADA);
    setContentView(R.layout.activity_create_new_habit);
    // http://stackoverflow.com/questions/2008558/displaying-a-default-date-in-a-edittext-widget
    EditText DateText = (EditText) findViewById(R.id.NewHabitDate);
    DateText.setText(formats.format(new Date()));
    int dayOfWeek = new DayOfWeek().getDayOfWeek();
    ((ToggleButton) findViewById(WeekDayButtonsid[dayOfWeek])).toggle();

}

From source file:org.browsexml.timesheetjob.web.SimpleWebApplicationContext.java

public void refresh() throws BeansException {
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue(new PropertyValue("commandClass", "org.springframework.beans.TestBean"));
    pvs.addPropertyValue(new PropertyValue("formView", "form"));
    //registerSingleton("/form.do", HoursWorkedFormController.class, pvs);

    //registerSingleton("/locale.do", LocaleChecker.class);

    //registerPrototype("/throwaway.do", TestThrowawayController.class);

    addMessage("test", Locale.ENGLISH, "test message");
    addMessage("test", Locale.CANADA, "Canadian & test message");
    addMessage("testArgs", Locale.ENGLISH, "test {0} message {1}");
    addMessage("testArgsFormat", Locale.ENGLISH, "test {0} message {1,number,#.##} X");

    registerSingleton(UiApplicationContextUtils.THEME_SOURCE_BEAN_NAME, DummyThemeSource.class);

    super.refresh();
}

From source file:org.hdiv.web.servlet.SimpleWebApplicationContext.java

public void refresh() throws BeansException {
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("commandClass", "org.hdiv.beans.TestBean");
    pvs.add("formView", "form");
    registerSingleton("/form.do", SimpleFormController.class, pvs);

    registerSingleton("/locale.do", LocaleChecker.class);

    addMessage("test", Locale.ENGLISH, "test message");
    addMessage("test", Locale.CANADA, "Canadian & test message");
    addMessage("testArgs", Locale.ENGLISH, "test {0} message {1}");
    addMessage("testArgsFormat", Locale.ENGLISH, "test {0} message {1,number,#.##} X");

    registerSingleton(UiApplicationContextUtils.THEME_SOURCE_BEAN_NAME, DummyThemeSource.class);

    registerSingleton("handlerMapping", BeanNameUrlHandlerMapping.class);
    registerSingleton("viewResolver", InternalResourceViewResolver.class);

    pvs = new MutablePropertyValues();
    pvs.add("location", "org/hdiv/web/context/WEB-INF/sessionContext.xml");
    registerSingleton("viewResolver2", XmlViewResolver.class, pvs);

    super.refresh();
}

From source file:org.jasig.springframework.web.portlet.SimplePortletApplicationContext.java

public void refresh() throws BeansException {
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("commandClass", "org.jasig.springframework.beans.TestBean");
    pvs.add("formView", "form");
    registerSingleton("/form.do", SimpleFormController.class, pvs);

    registerSingleton("/locale.do", LocaleChecker.class);

    addMessage("test", Locale.ENGLISH, "test message");
    addMessage("test", Locale.CANADA, "Canadian & test message");
    addMessage("testArgs", Locale.ENGLISH, "test {0} message {1}");
    addMessage("testArgsFormat", Locale.ENGLISH, "test {0} message {1,number,#.##} X");

    registerSingleton(UiApplicationContextUtils.THEME_SOURCE_BEAN_NAME, DummyThemeSource.class);

    registerSingleton("handlerMapping", BeanNameUrlHandlerMapping.class);
    registerSingleton("viewResolver", InternalResourceViewResolver.class);

    pvs = new MutablePropertyValues();
    pvs.add("location", "org/springframework/web/context/WEB-INF/sessionContext.xml");
    registerSingleton("viewResolver2", XmlViewResolver.class, pvs);

    super.refresh();
}

From source file:info.pancancer.arch3.reportbot.SlackReportBot.java

public void doWork() throws Exception {

    final HierarchicalINIConfiguration settings = Utilities.parseConfig(configFile);
    final PostgreSQL db = new PostgreSQL(settings);

    final SlackSession session = SlackSessionFactory
            .createWebSocketSlackSession(settings.getString(Constants.REPORT_TOKEN));
    session.addMessagePostedListener(new SlackMessagePostedListener() {
        @Override/*from  ww  w. j a  v a  2s.c  o  m*/
        public void onEvent(SlackMessagePosted event, SlackSession session) {
            Log.debug(event.toString());
            String namespace = settings.getString(Constants.REPORT_NAMESPACE).toUpperCase(Locale.CANADA);
            if (event.getSender().getUserName().equalsIgnoreCase(namespace)) {
                return;
            }
            // note that this ignores case
            String message = event.getMessageContent().toUpperCase(Locale.CANADA);

            boolean validMessage = false;
            // remove the '@' if necessary
            String dmIdentifer = "<@" + session.sessionPersona().getId() + ">";
            if (message.startsWith(dmIdentifer)) {
                message = message.replaceFirst(dmIdentifer, "").trim();
                // trim automatically inserted colon in some chat clients
                if (message.startsWith(":")) {
                    message = message.replaceFirst(":", "").trim();
                }
                validMessage = true;
            }
            // remove plain user name if needed
            if (message.startsWith(namespace)) {
                validMessage = true;
                message = message.replaceFirst(namespace, "").trim();
                Log.info("message was *" + message + "* ");
                // remove extra colon that the Mac client adds
                if (message.startsWith(":")) {
                    message = message.substring(1).trim();
                }
            }

            if (validMessage) {
                ReportAPI reportAPI = ReportAPIFactory.makeReportAPI(settings, db);
                SlackRenderer renderer = new SlackRenderer(reportAPI);
                SlackRenderer.FormattedMessage result = renderer.convertToResult(message);
                if (result.attachment != null) {
                    result.attachment.addMarkdownIn("text");
                }
                session.sendMessage(session.findChannelById(event.getChannel().getId()), result.message,
                        result.attachment);
            }
        }
    });

    int retries = 0;
    boolean retry = false;
    do {
        try {
            session.connect();
            do {
                Thread.sleep(SLEEP_IN_MILLISECONDS);
            } while (options.has(this.endlessSpec));
        } catch (Exception e) {
            Log.error("SlackBot connection issue", e);
            long waitTime = Math.min(getWaitTimeExp(retries), TEN_MINUTES_IN_MILLISECONDS);
            System.out.print(waitTime + "\n");
            // Wait for the result.
            Thread.sleep(waitTime);
        }
    } while (options.has(this.endlessSpec));
}