Example usage for java.util Locale Locale

List of usage examples for java.util Locale Locale

Introduction

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

Prototype

public Locale(String language) 

Source Link

Document

Construct a locale from a language code.

Usage

From source file:no.dusken.barweb.view.XListView.java

private Document generateXml(List<BarPerson> barPersons, Gjeng gjeng, List<Vare> varer, int lowlimit,
        Boolean panger) {/*www.  j  a  va  2 s.c om*/
    Document dom = null;
    //get an instance of factory
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {
        //get an instance of builder
        DocumentBuilder db = dbf.newDocumentBuilder();

        //create an instance of DOM
        dom = db.newDocument();

    } catch (ParserConfigurationException pce) {
        log.error("Error when generating x-list");
    }
    Element root = dom.createElement("xlist");
    root.setAttribute("gjeng", gjeng.getName());
    SimpleDateFormat dateformat = new SimpleDateFormat("d. MMMMMMMMM yyyy - HH:mm", new Locale("no"));
    root.setAttribute("generated", dateformat.format((new GregorianCalendar()).getTime()));
    root.setAttribute("magicNumber", String.valueOf(((new Random()).nextDouble() * 1000)));
    root.setAttribute("panger", panger.toString());
    dom.appendChild(root);
    Element personsEle = dom.createElement("barPersons");

    for (BarPerson p : barPersons) {
        Element personEle = createPersonElement(p, dom, lowlimit);
        personsEle.appendChild(personEle);
    }

    root.appendChild(personsEle);

    Element vareEle = dom.createElement("varer");

    for (Vare v : varer) {
        Element vare = createVareElement(v, dom);
        vareEle.appendChild(vare);
    }
    root.appendChild(vareEle);

    return dom;
}

From source file:fi.helsinki.opintoni.web.rest.privateapi.NewsResourceTest.java

@Test
public void thatEnglishStudentNewsAreReturned() throws Exception {
    flammaServer.expectEnglishStudentNews();

    mockMvc.perform(get("/api/private/v1/news/student").with(securityContext(studentSecurityContext()))
            .characterEncoding("UTF-8").contentType(MediaType.APPLICATION_JSON).locale(new Locale("en"))
            .accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
            .andExpect(content().contentType(WebConstants.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$").isArray()).andExpect(jsonPath("$", hasSize(1)))
            .andExpect(jsonPath("$[0].title").value("Title"))
            .andExpect(jsonPath("$[0].url").value("https://flamma.helsinki.fi/portal/home/content"))
            .andExpect(jsonPath("$[0].content").value("Content"));
}