Example usage for java.util Locale GERMANY

List of usage examples for java.util Locale GERMANY

Introduction

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

Prototype

Locale GERMANY

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

Click Source Link

Document

Useful constant for country.

Usage

From source file:org.bremersee.sms.GoyyaSmsService.java

/**
 * Creates the send time URL parameter value.
 * //from w w w  .j  a  v a 2 s  .c  o  m
 * @param sendTime
 *            the send time as {@link Date}
 * @return the send time URL parameter value
 */
protected String createSendTime(final Date sendTime) {
    if (sendTime == null || new Date(System.currentTimeMillis() + 1000L * 60L).after(sendTime)) {
        return null;
    }
    String sendTimePattern = StringUtils.isBlank(this.sendTimePattern) ? DEFAULT_SEND_TIME_PATTERN
            : this.sendTimePattern;
    SimpleDateFormat sdf = new SimpleDateFormat(sendTimePattern, Locale.GERMANY);
    sdf.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
    return sdf.format(sendTime);
}

From source file:org.codehaus.groovy.grails.web.binding.GrailsDataBinderTests.java

public void testNumberBinding() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addPreferredLocale(Locale.US);

    // JDK 1.4 and Spring 2.5.4 do not support localised parsing
    // of extra large numbers. Until we have resolved this problem,
    // we won't test a proper big integer.
    String securityNumber = "349,587,927,070";
    String bigNumber = "4,120,834,546";
    String credit = "1,203.45";
    String angle = "103.48674";
    request.addParameter("securityNumber", securityNumber);
    request.addParameter("bigNumber", bigNumber);
    request.addParameter("credit", credit);
    request.addParameter("angle", angle);

    TestBean testBean = new TestBean();
    GrailsDataBinder binder = GrailsDataBinder.createBinder(testBean, "testBean", request);
    binder.bind(request);//from   w w w .j  av a  2 s . c om

    assertEquals(349587927070L, testBean.getSecurityNumber().longValue());
    assertEquals(new BigInteger("4120834546"), testBean.getBigNumber());
    assertEquals(new BigDecimal("1203.45"), testBean.getCredit());
    assertEquals(103.48674D, testBean.getAngle().doubleValue(), 0.1D);

    // Now try German, which uses '.' and ',' instead of ',' and '.'.
    request = new MockHttpServletRequest();
    request.addPreferredLocale(Locale.GERMANY);

    securityNumber = "349.587.927.070";
    bigNumber = "4.120.834.546";
    credit = "1.203,45";
    angle = "103,48674";
    request.addParameter("securityNumber", securityNumber);
    request.addParameter("bigNumber", bigNumber);
    request.addParameter("credit", credit);
    request.addParameter("angle", angle);

    testBean = new TestBean();
    binder = GrailsDataBinder.createBinder(testBean, "testBean", request);
    binder.bind(request);

    assertEquals(349587927070L, testBean.getSecurityNumber().longValue());
    assertEquals(new BigInteger("4120834546"), testBean.getBigNumber());
    assertEquals(new BigDecimal("1203.45"), testBean.getCredit());
    assertEquals(103.48674D, testBean.getAngle().doubleValue(), 0.1D);
}

From source file:org.apache.openmeetings.web.app.WebSession.java

private void setUser(User u, Set<Right> rights) {
    String _sid = SID;//from w w  w. java 2 s.c o  m
    Long _recordingId = recordingId;
    Long _roomId = roomId;
    Invitation _i = i;
    replaceSession(); // required to prevent session fixation
    if (_sid != null) {
        SID = _sid;
    }
    if (_recordingId != null) {
        recordingId = _recordingId;
    }
    if (_roomId != null) {
        roomId = _roomId;
    }
    if (i != null) {
        i = _i;
    }
    userId = u.getId();
    if (rights == null || rights.isEmpty()) {
        this.rights = Collections.unmodifiableSet(u.getRights());
    } else {
        this.rights = Collections.unmodifiableSet(rights);
    }
    languageId = u.getLanguageId();
    externalType = u.getExternalType();
    tz = getBean(TimezoneUtil.class).getTimeZone(u);
    ISO8601FORMAT = FastDateFormat.getInstance(ISO8601_FORMAT_STRING, tz);
    setLocale(languageId == 3 ? Locale.GERMANY : LabelDao.languages.get(languageId));
    //FIXMW locale need to be set by User language first
    sdf = FastDateFormat.getDateTimeInstance(SHORT, SHORT, getLocale());
}

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

/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 *//*from ww w . ja  v a2  s .c om*/
@Test
public void testGetLastMillisecondWithCalendar() {
    Week w = new Week(52, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(1009756799999L, w.getLastMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        w.getLastMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

From source file:org.polymap.biotop.model.BiotopEntityProvider.java

@Override
public void modifyFeature(Entity entity, String propName, Object value) throws Exception {
    BiotopComposite biotop = (BiotopComposite) entity;
    if (propName.equals(getDefaultGeometry())) {
        if (value instanceof MultiPolygon) {
            biotop.geom().set((MultiPolygon) value);
        }//ww w. j  av  a  2 s .  co m
        // geometry buffer op results in Polygon (instead of MultiPolygon)
        // see #72: http://polymap.org/biotop/ticket/72
        else if (value instanceof Polygon) {
            MultiPolygon geom = new GeometryFactory().createMultiPolygon(new Polygon[] { (Polygon) value });
            biotop.geom().set(geom);
        } else {
            throw new IllegalStateException("Falscher Geometrietyp: " + value.getClass().getSimpleName());
        }
        ValueBuilder<AktivitaetValue> builder = repo.newValueBuilder(AktivitaetValue.class);
        AktivitaetValue prototype = builder.prototype();
        Calendar now = Calendar.getInstance(Locale.GERMANY);
        now.set(Calendar.MILLISECOND, 0);
        prototype.wann().set(now.getTime());
        prototype.wer().set(Polymap.instance().getUser().getName());
        prototype.bemerkung().set("nderung der Geometrie");
        biotop.bearbeitung().set(builder.newInstance());
    } else if (propName.equals(PROP.Name.toString())) {
        biotop.name().set((String) value);
    }
    //        else if (propName.equals( PROP.Biotoptyp.toString() )) {
    //            biotop.biotoptypArtNr().set( (String)value );
    //        }
    else if (propName.equals(PROP.Geprueft.toString())) {
        biotop.geprueft().set("ja".equals(value));
    } else if (propName.equals(PROP.Status.toString()) && value != null) {
        Status status = Status.all.forLabelOrSynonym((String) value);
        if (status != null) {
            biotop.status().set(status.id);
        }
    } else if (propName.equals(PROP.LKNr.toString())) {
        biotop.objnr_landkreise().set((String) value);
    }
    //        else {
    //            throw new RuntimeException( "Unhandled property: " + propName );
    //        }
}

From source file:com.mobileman.projecth.web.controller.patient.MedikamenteController.java

@Transactional
@RequestMapping(method = RequestMethod.POST, value = "/patient/medikamente_eingeben")
public String medicamentePost(HttpServletRequest request, HttpServletResponse response, Model model)
        throws UnsupportedEncodingException {
    KeepScroll.save(request, model);//ww w. j  a  va 2 s  .c o  m
    // save request parameters into map
    request.setCharacterEncoding("UTF-8");
    ViewState.copyViewState(request, model);
    String diseaseCode = request.getParameter("selectdisease");
    model.addAttribute("selected_disease_code", diseaseCode);

    String selectunits = request.getParameter("selectunits");
    model.addAttribute("selectedUnits", selectunits);

    String takingFrequnecyStr = request.getParameter("select_taking_frequency");
    model.addAttribute("select_taking_frequency", takingFrequnecyStr);
    MedicationFrequency medicationFrequency = (takingFrequnecyStr == null || takingFrequnecyStr.equals("0"))
            ? null
            : MedicationFrequency.valueOf(takingFrequnecyStr);

    String selectedHistoryMedication = request.getParameter("selecthistory");
    model.addAttribute("selected_history_medication", selectedHistoryMedication);

    Long patientMedicationId = NumUtils.convert2long(request.getParameter("patientMedicationId"));
    if (patientMedicationId != null) {
        return medicamenteEditPost(request, response, model, patientMedicationId);
    }

    boolean error = false;

    if (StringUtils.isNotBlank(request.getParameter("search.x"))) {
        model.addAttribute("wasSearch", true);
        // search
        //
        String filter = request.getParameter("filter");
        List<Medication> medications = null;
        try {
            if (StringUtils.isNotBlank(filter)) {
                medications = medicationService.findAllByNameOrPzn(filter, Locale.GERMANY);
            } else {
                // error
                model.addAttribute("errorsearchnodata", true);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            model.addAttribute("errorsearch", true);
        }
        // clear fields
        setupFields(model, null, null, null);
        if (medications != null) {
            // store result
            // if zero clear text boxes
            // if only one save into text boxes
            // if more fill list
            if (medications.size() == 0) {
                model.addAttribute("infosearchnotfound", true);
            } else if (medications.size() == 1) {
                Medication tmp = medications.get(0);
                setupFields(model, tmp.getName(), tmp.getPzn(), tmp.getStandardUnitSize());
                // setup fields
            } else if (medications.size() > 1) {
                // fill combo
                model.addAttribute("searchresult", medications);
            }
        }
    } else {

        model.addAttribute("wasEnter", true);
        Long medid = null;
        // find for mednumer
        String pzn = request.getParameter("pzn");
        try {

            Medication med = medicationService.findByPzn(pzn, Locale.GERMANY);
            if (med != null) {
                medid = med.getId();
            }
        } catch (Exception e) {
        }

        if (medid == null) {
            // insert new medicine
            String name = request.getParameter("name");
            String units = request.getParameter("unitssize");

            if (StringUtils.isBlank(name)) {
                error = true;
                model.addAttribute("errorname", true);
            }
            if (StringUtils.isBlank(units)) {
                error = true;
                model.addAttribute("errorunits", true);
            }

            if (!error) {
                try {
                    Medication med = new Medication();
                    med.setLocale(Locale.GERMANY);
                    med.setName(name);
                    if (pzn != null && pzn.trim().length() > 0) {
                        med.setPzn(new PznBarcode());
                        med.getPzn().setNumber(pzn);
                    }

                    med.setCreatedatetime(new Date());
                    med.setStandardUnitSize(units);
                    medid = medicationService.save(med);
                } catch (Exception e) {
                    // show error
                    model.addAttribute("erroraddmed", true);
                }
            }
        }

        Double units = NumUtils.convert2double(selectunits);
        if (units == null) {
            model.addAttribute("errorselectunits", true);
            error = true;
        }

        if (StringUtils.isBlank(diseaseCode) || "0".equals(diseaseCode)) {
            model.addAttribute("errordisease", true);
            error = true;
        }

        if (medicationFrequency == null) {
            model.addAttribute("error_taking_frequency", true);
            error = true;
        }

        String startDateStr = request.getParameter("consum_start_date");
        String endDateStr = request.getParameter("consum_end_date");

        Date dateStart = DateUtils.normalStr2date(startDateStr);
        Date endDate = DateUtils.normalStr2date(endDateStr);
        if (dateStart == null) {
            model.addAttribute("error_consum_start_date", true);
            error = true;
        }

        if (endDate == null) {
            model.addAttribute("error_consum_end_date", true);
            error = true;
        }

        if (dateStart != null && endDate != null) {
            if (endDate.before(dateStart)) {
                model.addAttribute("error_consum_end_date", true);
                error = true;
            }
        }

        String comment = request.getParameter("comment");

        if (!error && medid != null) {
            Disease disease = diseasService.findByCode(diseaseCode);
            Patient patient = new DataHolder(request).getPatient();

            try {
                patientMedicationService.addConsumedMedication(patient.getId(), disease.getId(), medid, units,
                        medicationFrequency, dateStart, endDate, comment);

                model.addAttribute("infoconsume", true);
            } catch (Exception ex) {
                model.addAttribute("errorconsume", true);
            }
        }
    }

    String result = medicamenteEingebenGet(request, response, model);
    if (!error) {
        setupFields(model, null, null, null);
    }

    return result;
}

From source file:de.baumann.hhsmoodle.fragmentsMain.FragmentGrades.java

private void actualPoint(double percentText, TextView text) {

    double actPointsLong = (percentText / 100) * maxPoints;
    String actPointsString = String.format(Locale.GERMANY, "%.1f", actPointsLong);
    text.setText(String.valueOf(String.valueOf(actPointsString)));
}

From source file:org.kepler.configuration.SerializationComparisonTest.java

/**
 * test locale support/*from   w w w. ja v a2  s .co m*/
 */
public void testCommonsLocaleSerialization() {
    try {
        Module m = getModule("configuration-manager");
        File f = new File(m.getConfigurationsDir(), "test.xml");
        Locale l = Locale.GERMANY;

        //we ask to load test.xml with a german locale.  there's a german test.xml
        //(test_de_DE.xml) so we should not load test.xml
        CommonsConfigurationReader ccr = new CommonsConfigurationReader();
        ConfigurationProperty cp = ccr.loadConfiguration(m, f, l);
        assertTrue(cp == null);

        //we should load test_de_DE.xml when using the locale de_DE
        f = new File(m.getConfigurationsDir(), "test_de_DE.xml");
        cp = ccr.loadConfiguration(m, f, l);
        assertTrue(cp != null);

        //we should not load this file because we want a chinese locale, but we're 
        //trying to load a german file when another default file exists
        l = Locale.CHINA;
        cp = ccr.loadConfiguration(m, f, l);
        assertTrue(cp == null);

        //this file should load because we're asking for chinese and there is
        //no chinese file and we're asking to load a file with no locale
        //designator.
        f = new File(m.getConfigurationsDir(), "test.xml");
        cp = ccr.loadConfiguration(m, f, l);
        assertTrue(cp != null);
    } catch (Exception e) {
        fail("No exception should have been thrown in testCommonsLocaleSerialization: " + e.getMessage());
    }
}

From source file:org.apache.sling.i18n.it.ResourceBundleProviderIT.java

private void assertMessages(final String key, final String deMessage, final String deDeMessage,
        final String frMessage) {
    new Retry(RETRY_TIMEOUT_MSEC) {
        @Override//from   w  w  w. j  a  v a  2s  .c o m
        protected void exec() {
            {
                final ResourceBundle deDE = resourceBundleProvider.getResourceBundle(Locale.GERMANY); // this is the resource bundle for de_DE
                assertNotNull(deDE);
                assertEquals(deDeMessage, deDE.getString(key));
            }
            {
                final ResourceBundle de = resourceBundleProvider.getResourceBundle(Locale.GERMAN);
                assertNotNull(de);
                assertEquals(deMessage, de.getString(key));
            }
            {
                final ResourceBundle fr = resourceBundleProvider.getResourceBundle(Locale.FRENCH);
                assertNotNull(fr);
                assertEquals(frMessage, fr.getString(key));
            }
        }
    };
}

From source file:com.squarespace.template.plugins.CoreFormattersTest.java

@Test
public void testDateLocale() throws CodeException {
    String tzNewYork = "America/New_York";
    String format = "%B %d";

    assertEquals(formatDate(format, MAY_13_2013_010000_UTC, tzNewYork, Locale.GERMANY), "Mai 12");
    assertEquals(formatDate(format, MAY_13_2013_010000_UTC, tzNewYork, Locale.FRENCH), "mai 12");
    assertEquals(formatDate(format, MAY_13_2013_010000_UTC, tzNewYork, new Locale("es", "MX")), "mayo 12");
    assertEquals(formatDate(format, MAY_13_2013_010000_UTC, tzNewYork, new Locale("es", "SP")), "mayo 12");

    format = "%A";
    assertEquals(formatDate(format, NOV_15_2013_123030_UTC, tzNewYork, Locale.GERMANY), "Freitag");
    assertEquals(formatDate(format, NOV_15_2013_123030_UTC, tzNewYork, new Locale("es", "MX")), "viernes");
}