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:com.inkubator.hrm.web.converter.OvertimeImplCalculationMethodConverter.java

@Override
public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));
    String messages = StringUtils.EMPTY;
    Integer data = (Integer) value;
    if (Objects.equals(data, HRMConstant.OVERTIME_CALCULATION_STATIC)) {
        messages = resourceBundle.getString("overTimeImplementation.static");
    } else if (Objects.equals(data, HRMConstant.OVERTIME_CALCULATION_RELATIVE)) {
        messages = resourceBundle.getString("overTimeImplementation.relative");
    }//w  ww .  jav  a2  s .  co  m
    return messages;

}

From source file:no.dusken.aranea.admin.editor.CalendarEditor.java

@Override
public String getAsText() {
    DateFormat formatter = new SimpleDateFormat(format, new Locale("no"));
    Calendar cal = (GregorianCalendar) getValue();
    if (cal != null) {
        return formatter.format(cal.getTime());
    } else {//from  w w  w . jav  a2  s . c  o  m
        return null;
    }
}

From source file:com.inkubator.hrm.web.converter.ApprovalDefinitionConverter.java

@Override
public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));
    String messages = StringUtils.EMPTY;
    String data = (String) value;
    switch (data) {
    case HRMConstant.REIMBURSEMENT:
        messages = resourceBundle.getString("reimbursment.reimbursment");
        break;//w  w w  .  jav a2  s  .co  m
    case HRMConstant.RECRUIT_MPP_APPLY:
        messages = resourceBundle.getString("approvaldefinition.recruit_mpp_apply");
        break;
    case HRMConstant.LEAVE:
        messages = resourceBundle.getString("global.leave");
        break;
    case HRMConstant.OVERTIME:
        messages = resourceBundle.getString("global.overtime");
        break;
    case HRMConstant.RECRUITMENT_REQUEST:
        messages = resourceBundle.getString("recruitment.recruitment_request");
        break;
    case HRMConstant.EMP_CORRECTION_ATTENDANCE:
        messages = resourceBundle.getString("emp_correction_attendance.correction_attendance");
        break;
    case HRMConstant.LOAN:
        messages = resourceBundle.getString("loan.loan");
        break;
    case HRMConstant.SHIFT_SCHEDULE:
        messages = resourceBundle.getString("global.schedule_shift");
        break;
    case HRMConstant.BUSINESS_TRAVEL:
        messages = resourceBundle.getString("businesstravel.business_travel");
        break;
    case HRMConstant.PERMIT:
        messages = resourceBundle.getString("global.permit");
        break;
    case HRMConstant.EMPLOYEE_CAREER_TRANSITION:
        messages = resourceBundle.getString("emp_career_transition.career_transition");
        break;
    case HRMConstant.EMPLOYEE_ELIMINATION:
        messages = resourceBundle.getString("approvaldefinition.process_request_career_elimination");
        break;
    case HRMConstant.APPROVAL_PROCESS:
        messages = resourceBundle.getString("approvaldefinition.approval_process");
        break;
    case HRMConstant.APPROVAL_TYPE_POSITION:
        messages = resourceBundle.getString("position.position");
        break;
    case HRMConstant.APPROVAL_TYPE_DEPARTMENT:
        messages = resourceBundle.getString("department.department");
        break;
    case HRMConstant.APPROVAL_TYPE_INDIVIDUAL:
        messages = resourceBundle.getString("global.individual");
        break;
    default:
        messages = data;
        break;
    }

    return messages;

}

From source file:com.inkubator.hrm.web.converter.PaySalaryJurnalTypeJurnalConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));

    String messages = StringUtils.EMPTY;
    Integer data = (Integer) value;
    if (data == HRMConstant.PAY_SALARY_JURNAL_TYPE_DEBET) {
        messages = resourceBundle.getString("paySalaryJurnal.debet");
    } else if (data == HRMConstant.PAY_SALARY_JURNAL_TYPE_KREDIT) {
        messages = resourceBundle.getString("paySalaryJurnal.kredit");
    }/*  w ww.  j av a2s  .c  om*/
    return messages;
}

From source file:com.inkubator.hrm.web.converter.RomanovConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));

    Integer data = (Integer) value;
    String messages = String.valueOf(RomanovUtil.convertToRoman(data));

    return messages;
}

From source file:com.inkubator.hrm.web.converter.PaySalaryJurnalModelJurnalConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));

    String messages = StringUtils.EMPTY;
    Integer data = (Integer) value;
    if (data == HRMConstant.PAY_SALARY_JURNAL_MODEL_CASH) {
        messages = resourceBundle.getString("paySalaryJurnal.cash");
    } else if (data == HRMConstant.PAY_SALARY_JURNAL_MODEL_TRANSFER) {
        messages = resourceBundle.getString("paySalaryJurnal.transfer");
    }/*w  w  w.  j  ava2  s  .  c om*/
    return messages;
}

From source file:com.inkubator.sms.gateway.util.SpringSecurityContextListenerFix.java

@Override
public void requestInitialized(ServletRequestEvent requestEvent) {
    super.requestInitialized(requestEvent);
    HttpServletRequest request = (HttpServletRequest) requestEvent.getServletRequest();
    HttpSession sesion = request.getSession(false);
    Locale idioma;//from  w ww.j a v  a  2  s  .  com
    if (sesion != null) {
        //            System.out.println(sesion.getAttribute(HRMConstant.BAHASA_ACTIVE).toString());
        if (sesion.getAttribute(SMSGATEWAY.BAHASA_ACTIVE) != null) {
            idioma = new Locale(sesion.getAttribute(SMSGATEWAY.BAHASA_ACTIVE).toString());
        } else {
            idioma = new Locale("in");
        }
        LocaleContextHolder.setLocale(idioma);
    } else {
        idioma = new Locale("in");
        LocaleContextHolder.setLocale(idioma);
    }
}

From source file:com.salesmanager.core.util.LocaleUtil.java

public static Locale getLocale(String lang) {

    if (StringUtils.isBlank(lang)) {
        return getDefaultLocale();
    }/*  www. ja  va2s .  c  o m*/

    if (lang.equals(Constants.ENGLISH_CODE)) {
        return Locale.ENGLISH;
    } else if (lang.equals(Constants.FRENCH_CODE)) {
        return Locale.FRENCH;
    } else {
        log.warn("Resources for this language " + lang + " may not be handled by this system");
        return new Locale(lang);
    }

}

From source file:com.inkubator.hrm.web.converter.PaySalaryComponentFormulaConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));

    String messages = StringUtils.EMPTY;
    Integer data = (Integer) value;
    if (Objects.equals(data, 1)) {
        messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_tunjangan");
    } else if (Objects.equals(data, -1)) {
        messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_potongan");
    } else if (Objects.equals(data, 0)) {
        messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_subsidi");
    }//from  w  ww.j a v  a  2s . co m
    return messages;
}

From source file:com.examples.with.different.packagename.StringUtilsEqualsIndexOfTest.java

@Test
public void testContainsIgnoreCase_LocaleIndependence() {
    final Locale[] locales = { Locale.ENGLISH, new Locale("tr"), Locale.getDefault() };

    final String[][] tdata = { { "i", "I" }, { "I", "i" }, { "\u03C2", "\u03C3" }, { "\u03A3", "\u03C2" },
            { "\u03A3", "\u03C3" }, };

    final String[][] fdata = { { "\u00DF", "SS" }, };

    for (final Locale testLocale : locales) {
        Locale.setDefault(testLocale);
        for (int j = 0; j < tdata.length; j++) {
            assertTrue(Locale.getDefault() + ": " + j + " " + tdata[j][0] + " " + tdata[j][1],
                    StringUtils.containsIgnoreCase(tdata[j][0], tdata[j][1]));
        }/*from  www.j a  v  a 2  s  . c o  m*/
        for (int j = 0; j < fdata.length; j++) {
            assertFalse(Locale.getDefault() + ": " + j + " " + fdata[j][0] + " " + fdata[j][1],
                    StringUtils.containsIgnoreCase(fdata[j][0], fdata[j][1]));
        }
    }
}