Example usage for java.util Locale GERMAN

List of usage examples for java.util Locale GERMAN

Introduction

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

Prototype

Locale GERMAN

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

Click Source Link

Document

Useful constant for language.

Usage

From source file:divya.myvision.TessActivity.java

public void setLang(String lang) {
    Locale locale;//from w ww.  ja va2  s  .co  m
    if (lang.equals("Spanish")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                Locale locSpanish = new Locale("spa", "MEX");
                tts.setLanguage(locSpanish);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("spa", "MEX");
    }

    else if (lang.equals("French")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.FRENCH);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("fr");
    } else if (lang.equals("Japanese")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.JAPANESE);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("ja");
    } else if (lang.equals("Chinese")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.CHINESE);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("zh");
    } else if (lang.equals("German")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.GERMAN);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("de");
    } else if (lang.equals("Italian")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.ITALIAN);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("it");
    } else if (lang.equals("Korean")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.KOREAN);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("ko");
    } else if (lang.equals("Hindi")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                Locale locHindhi = new Locale("hi");
                tts.setLanguage(locHindhi);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("hi");
    } else if (lang.equals("Russian")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                Locale locHindhi = new Locale("ru");
                tts.setLanguage(locHindhi);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("ru");
    } else {
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.US);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("en");
    }
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.setLocale(locale);
    this.getApplicationContext().getResources().updateConfiguration(config, null);

}

From source file:de.damdi.fitness.activity.create_exercise.CreateExerciseActivity.java

/** Saves the created exercise. */
private void saveExercise() {
    BasicDataFragment basicDataFragment = (BasicDataFragment) mSectionsPagerAdapter.getItem(0);
    ImageFragment imageFragment = (ImageFragment) mSectionsPagerAdapter.getItem(1);
    MuscleDataFragment muscleDataFragment = (MuscleDataFragment) mSectionsPagerAdapter.getItem(2);
    EquipmentDataFragment equipmentDataFragment = (EquipmentDataFragment) mSectionsPagerAdapter.getItem(3);

    DataProvider dataProvider = new DataProvider(this);

    // handle names
    Map<Locale, String> translationMap = new HashMap<Locale, String>();
    String ex_name_english = basicDataFragment.getExerciseNameEnglish();
    String ex_name_german = basicDataFragment.getExerciseNameGerman();

    if (ex_name_english.equals("") && ex_name_german.equals("")) {
        Log.v(TAG, "User did not enter an exercise name.");
        Toast.makeText(this, getString(R.string.provide_name), Toast.LENGTH_LONG).show();

        return;/* ww w.  ja v  a 2s.  c  o m*/
    }

    if (!ex_name_english.equals("")) {
        if (dataProvider.getExerciseByName(ex_name_english) != null) {
            Toast.makeText(this, getString(R.string.name_already_used), Toast.LENGTH_LONG).show();
            return;
        }

        translationMap.put(Locale.ENGLISH, ex_name_english);
    }

    if (!ex_name_german.equals("")) {
        if (dataProvider.getExerciseByName(ex_name_german) != null) {
            Toast.makeText(this, getString(R.string.name_already_used), Toast.LENGTH_LONG).show();
            return;
        }

        translationMap.put(Locale.GERMAN, ex_name_german);
    }

    // handle description
    String description = basicDataFragment.getExerciseDescription();

    // handle muscle
    SortedSet<Muscle> muscleList = new TreeSet<Muscle>(muscleDataFragment.getMuscles());

    // handle equipment
    SortedSet<SportsEquipment> equipmentList = new TreeSet<SportsEquipment>(
            equipmentDataFragment.getSportsEquipment());

    // save image
    Uri image = imageFragment.getImage();
    List<File> imageList = new ArrayList<File>();

    if (image != null) {
        DataHelper dataHelper = new DataHelper(this);
        String image_name = dataHelper.copyImageToCustomImageFolder(image);
        imageList.add(new File(image_name));
    }

    ExerciseType.Builder exerciseBuilder = new ExerciseType.Builder(translationMap.values().iterator().next())
            .description(description).translationMap(translationMap).activatedMuscles(muscleList)
            .neededTools(equipmentList).imagePath(imageList);
    ExerciseType ex = exerciseBuilder.build();

    // save exercise
    boolean succ = dataProvider.saveCustomExercise(ex);

    if (!succ) {
        Toast.makeText(this, getString(R.string.could_not_save_exercise), Toast.LENGTH_LONG).show();
    } else {
        Toast.makeText(this, getString(R.string.exercise_saved), Toast.LENGTH_LONG).show();
    }
}

From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelImportServiceAttributesIntegrationTest.java

/**
 * Tests if importing Building Block the attribute values will be not deleted. This case is tested with
 * {@link InformationSystemRelease}, but it is actual to all Building blocks.
 * //from   w ww.j a v  a2  s.co m
 * @throws Exception if an exception occurs
 */
@Test
public void testAttributesExistAfterISRImport() {
    InformationSystem is = testDataHelper.createInformationSystem("I");
    TypeOfStatus typeOfStatus = InformationSystemRelease.TypeOfStatus.CURRENT;
    InformationSystemRelease isr = testDataHelper.createInformationSystemRelease(is, "i1", TEST_DESCRIPTION,
            "1.1.2005", "31.12.2005", typeOfStatus);

    TextAV textAV1 = createTextAttribute("1");
    TextAV textAV2 = createTextAttribute("2");
    TextAV textAV3 = createTextAttribute("3");

    testDataHelper.createAVA(isr, textAV1);
    testDataHelper.createAVA(isr, textAV2);
    testDataHelper.createAVA(isr, textAV3);

    final HSSFWorkbook workbook = new HSSFWorkbook();
    final HSSFSheet sheet = workbook.createSheet();
    final HSSFRow row = sheet.createRow(0);
    final Cell nameCell = row.createCell(0);
    final Cell descriptionCell = row.createCell(1);

    BuildingBlockHolder buildingBlockHolder = new BuildingBlockHolder(isr, nameCell, descriptionCell);
    buildingBlockHolder.setClone(BuildingBlockUtil.clone(isr));

    LandscapeData landscapeData = new LandscapeData();
    landscapeData.addBuildingBlock(buildingBlockHolder);

    final Map<String, CellValueHolder> attributesMap = Maps.newHashMap();
    final Cell cell = row.createCell(2);
    cell.setCellValue(UPDATED_TEXT_AV1);
    CellValueHolder cellValueHolder = new CellValueHolder(cell);

    attributesMap.put("TextAT1", cellValueHolder);
    landscapeData.getAttributes().add(new BuildingBlockAttributes(isr, attributesMap));

    landscapeData.setLocale(Locale.GERMAN);
    excelImportService.importLandscapeData(landscapeData);

    InformationSystemRelease isrLoadedFromDb = isrService.loadObjectById(isr.getId());
    Set<AttributeValueAssignment> attributeValueAssignments = isrLoadedFromDb.getAttributeValueAssignments();
    assertEquals("Some attribute value assignments were deleted.", 3, attributeValueAssignments.size());

    checkAttributeValues(attributeValueAssignments, textAV1.getAbstractAttributeType(), UPDATED_TEXT_AV1);
    checkAttributeValues(attributeValueAssignments, textAV2.getAbstractAttributeType(), "Text Value2");
    checkAttributeValues(attributeValueAssignments, textAV3.getAbstractAttributeType(), "Text Value3");
}

From source file:com.hybris.backoffice.cockpitng.dataaccess.facades.DefaultPlatformPermissionFacadeStrategyTest.java

@Test
public void testGetReadableLocalesForInstanceAsAdmin() {
    final Set<Locale> locales = new HashSet<Locale>();
    locales.add(Locale.ENGLISH);//from ww  w.ja v  a 2  s. c om
    locales.add(Locale.GERMAN);
    locales.add(Locale.JAPAN);

    final DefaultPlatformPermissionFacadeStrategy permissionFacade = new DefaultPlatformPermissionFacadeStrategy() {
        @Override
        public Set<Locale> getAllReadableLocalesForCurrentUser() {
            return locales;
        }

        @Override
        public Set<Locale> getAllWritableLocalesForCurrentUser() {
            return locales;
        }
    };

    permissionFacade.setCatalogTypeService(catalogTypeService);
    permissionFacade.setCommonI18NService(commonI18NService);
    permissionFacade.setUserService(userService);

    Mockito.when(userService.isAdmin(user)).thenReturn(true);

    LanguageModel german = new LanguageModel();
    german.setIsocode(GERMAN_ISO_CODE);
    catalog.setLanguages(Collections.singletonList(german));

    final Set<Locale> readableLocalesForInstance = permissionFacade.getReadableLocalesForInstance(product);

    //Even though catalog is restricted for geramn language only - in case of admin, facade returns all readable languages of the admin user - all defined. In this test - English
    Assert.assertTrue(readableLocalesForInstance.containsAll(locales));
}

From source file:de.randi2.testUtility.utility.Bootstrap.java

public void init() throws ServiceException {
    long time1 = System.nanoTime();

    EntityTransaction transaction = entityManager.getTransaction();
    transaction.begin();/*from www.ja  va2 s.  c om*/

    entityManager.persist(Role.ROLE_INVESTIGATOR);
    entityManager.persist(Role.ROLE_USER);
    entityManager.persist(Role.ROLE_STATISTICAN);
    entityManager.persist(Role.ROLE_MONITOR);
    entityManager.persist(Role.ROLE_P_INVESTIGATOR);
    entityManager.persist(Role.ROLE_ANONYMOUS);
    entityManager.persist(Role.ROLE_ADMIN);

    Role.ROLE_ADMIN.getRolesToAssign().add(Role.ROLE_ADMIN);
    entityManager.merge(Role.ROLE_ADMIN);

    transaction.commit();
    transaction.begin();
    Role roleAdmin = (Role) entityManager.find(Role.class, 1L);
    roleAdmin.getRolesToAssign().add(roleAdmin);
    entityManager.merge(roleAdmin);
    transaction.commit();

    transaction.begin();

    Person cp1 = new Person();
    cp1.setFirstname("Contact");
    cp1.setSurname("Person");
    cp1.setEmail("randi2@action.ms");
    cp1.setPhone("1234567");
    cp1.setSex(Gender.MALE);

    Person cp2 = new Person();
    cp2.setFirstname("Contact");
    cp2.setSurname("Person");
    cp2.setEmail("randi2@action.ms");
    cp2.setPhone("1234567");
    cp2.setSex(Gender.MALE);

    Person adminP = new Person();
    adminP.setFirstname("Max");
    adminP.setSurname("Administrator");
    adminP.setEmail("randi2@action.ms");
    adminP.setPhone("1234567");
    adminP.setSex(Gender.MALE);

    Login adminL = new Login();
    adminL.setUsername("admin@trialsite1.de");
    adminL.setPassword(passwordEncoder.encodePassword("1$heidelberg", saltSourceUser.getSalt(adminL)));
    adminL.setPerson(adminP);
    adminL.setPrefLocale(Locale.GERMANY);
    adminL.addRole(Role.ROLE_ADMIN);
    adminL.setPrefLocale(Locale.GERMAN);
    entityManager.persist(adminL);
    TrialSite trialSite = new TrialSite();
    trialSite.setCity("Heidelberg");
    trialSite.setCountry("Germany");
    trialSite.setName("Trial Site 1");
    trialSite.setPostcode("69120");
    trialSite.setStreet("INF");
    trialSite.setPassword(
            passwordEncoder.encodePassword("1$heidelberg", saltSourceTrialSite.getSystemWideSalt()));
    trialSite.setContactPerson(cp1);
    trialSite.getMembers().add(adminP);
    entityManager.persist(trialSite);
    transaction.commit();

    rolesAndRights.registerPerson(adminL);
    rolesAndRights.grantRights(adminL, trialSite);

    rolesAndRights.grantRights(trialSite, trialSite);

    entityManager.clear();

    AnonymousAuthenticationToken authToken = new AnonymousAuthenticationToken("anonymousUser", adminL,
            new ArrayList<GrantedAuthority>(adminL.getAuthorities()));
    // Perform authentication
    SecurityContextHolder.getContext().setAuthentication(authToken);
    SecurityContextHolder.getContext().getAuthentication().setAuthenticated(true);

    Person userPInv = new Person();
    userPInv.setFirstname("Maxi");
    userPInv.setSurname("Investigator");
    userPInv.setEmail("randi2@action.ms");
    userPInv.setPhone("1234567");
    //      userPInv.setTrialSite(trialSite);

    Login userLInv = new Login();
    userLInv.setUsername("investigator@trialsite1.de");
    userLInv.setPassword("1$heidelberg");
    userLInv.setPerson(userPInv);
    userLInv.setPrefLocale(Locale.GERMANY);
    userLInv.addRole(Role.ROLE_INVESTIGATOR);
    userLInv.setPrefLocale(Locale.GERMAN);
    userService.create(userLInv, trialSite);

    Person userPPInv = new Person();
    userPPInv.setFirstname("Max");
    userPPInv.setSurname("PInvestigator");
    userPPInv.setEmail("randi2@action.ms");
    userPPInv.setPhone("1234567");
    userPPInv.setSex(Gender.MALE);
    //      userPPInv.setTrialSite(trialSite);

    Login userLPInv = new Login();
    userLPInv.setUsername("p_investigator@trialsite1.de");
    userLPInv.setPassword("1$heidelberg");
    userLPInv.setPerson(userPPInv);
    userLPInv.setPrefLocale(Locale.GERMANY);
    userLPInv.addRole(Role.ROLE_P_INVESTIGATOR);
    userLPInv.setPrefLocale(Locale.GERMAN);
    userService.create(userLPInv, trialSite);

    Person userP = new Person();
    userP.setFirstname("Maxi");
    userP.setSurname("Monitor");
    userP.setEmail("randi2@action.ms");
    userP.setPhone("1234567");
    userP.setSex(Gender.FEMALE);
    //      userP.setTrialSite(trialSite);
    Login userL = new Login();
    userL.setUsername("monitor@trialsite1.de");
    userL.setPassword("1$heidelberg");
    userL.setPerson(userP);
    userL.setPrefLocale(Locale.GERMANY);
    userL.addRole(Role.ROLE_MONITOR);
    userL.setPrefLocale(Locale.GERMAN);
    userService.create(userL, trialSite);

    userP = new Person();
    userP.setFirstname("Max");
    userP.setSurname("Statistican");
    userP.setEmail("randi2@action.ms");
    userP.setPhone("1234567");
    userP.setSex(Gender.MALE);
    //      userP.setTrialSite(trialSite);

    userL = new Login();
    userL.setUsername("statistican@trialsite1.de");
    userL.setPassword("1$heidelberg");
    userL.setPerson(userP);
    userL.setPrefLocale(Locale.GERMANY);
    userL.addRole(Role.ROLE_STATISTICAN);
    userL.setPrefLocale(Locale.GERMAN);
    userService.create(userL, trialSite);

    TrialSite trialSite1 = new TrialSite();
    trialSite1.setCity("Heidelberg");
    trialSite1.setCountry("Germany");
    trialSite1.setName("Trial Site 2");
    trialSite1.setPostcode("69120");
    trialSite1.setStreet("INF");
    trialSite1.setPassword("1$heidelberg");
    trialSite1.setContactPerson(cp2);

    trialSiteService.create(trialSite1);

    // create test trial

    trialSite1 = trialSiteService.getObject(trialSite1.getId());
    Person userPInv2 = new Person();
    userPInv2.setFirstname("Max");
    userPInv2.setSurname("Investigator");
    userPInv2.setEmail("randi2@action.ms");
    userPInv2.setPhone("1234567");
    userPInv2.setSex(Gender.MALE);

    Login userLInv2 = new Login();
    userLInv2.setUsername("investigator@trialsite2.de");
    userLInv2.setPassword("1$heidelberg");
    userLInv2.setPerson(userPInv2);
    userLInv2.setPrefLocale(Locale.GERMANY);
    userLInv2.addRole(Role.ROLE_INVESTIGATOR);
    userLInv2.setPrefLocale(Locale.GERMAN);
    userService.create(userLInv2, trialSite1);

    // create test trial
    System.out.println("create user: " + (System.nanoTime() - time1) / 1000000 + " ms");
    time1 = System.nanoTime();
    // create test trial
    authToken = new AnonymousAuthenticationToken("anonymousUser", userLPInv,
            new ArrayList<GrantedAuthority>(userLPInv.getAuthorities()));
    // Perform authentication
    SecurityContextHolder.getContext().setAuthentication(authToken);
    SecurityContextHolder.getContext().getAuthentication().setAuthenticated(true);

    trialSite1 = entityManager.find(TrialSite.class, trialSite1.getId());
    Trial trial = new Trial();
    trial.setAbbreviation("bs");
    trial.setName("Block study");
    trial.setDescription("Block study with two treatment arms and blocksize 8, stratified by trial site");
    trial.setGenerateIds(true);
    trial.setStratifyTrialSite(true);
    trial.setSponsorInvestigator(userPPInv);
    trial.setLeadingSite(trialSite);
    trial.addParticipatingSite(trialSite);
    trial.addParticipatingSite(trialSite1);
    trial.setStartDate(new GregorianCalendar(2009, 0, 1));
    trial.setEndDate(new GregorianCalendar(2010, 11, 1));
    trial.setStatus(TrialStatus.ACTIVE);

    BlockRandomizationConfig randConf = new BlockRandomizationConfig();
    randConf.setMaximum(8);
    randConf.setMinimum(8);
    randConf.setType(TYPE.ABSOLUTE);

    trial.setRandomizationConfiguration(randConf);

    TreatmentArm arm1 = new TreatmentArm();
    arm1.setDescription("First Treatment");
    arm1.setName("arm1");
    arm1.setDescription("description");
    arm1.setPlannedSubjects(200);

    TreatmentArm arm2 = new TreatmentArm();
    arm2.setDescription("Second Treatment");
    arm2.setName("arm2");
    arm2.setDescription("description");
    arm2.setPlannedSubjects(200);

    trial.setTreatmentArms(new HashSet<TreatmentArm>(Arrays.asList(arm1, arm2)));

    DichotomousCriterion cr = new DichotomousCriterion();
    cr.setName("SEX");
    cr.setOption1("M");
    cr.setOption2("F");
    DichotomousCriterion cr1 = new DichotomousCriterion();
    cr1.setOption1("1");
    cr1.setOption2("2");
    cr1.setName("Tum.Status");
    DichotomousCriterion cr2 = new DichotomousCriterion();
    cr2.setOption1("1");
    cr2.setOption2("2");
    cr2.setName("Fit.Level");
    try {

        cr.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "M" })));

        cr.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "F" })));

        cr1.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "1" })));
        cr1.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "2" })));
        cr2.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "1" })));
        cr2.addStrata(new DichotomousConstraint(Arrays.asList(new String[] { "2" })));

        trial.addCriterion(cr);
        trial.addCriterion(cr1);
        trial.addCriterion(cr2);

    } catch (ConstraintViolatedException e) {
        BoxedException.throwBoxed(e);
    }

    try {
        trialService.create(trial);
    } catch (ConstraintViolationException e) {
        // TODO: handle exception
        System.out.println(e.getMessage());
        for (ConstraintViolation<?> v : e.getConstraintViolations()) {
            System.out.println(v.getPropertyPath() + " " + v.getMessage());
        }

    }

    System.out.println("create trial: " + (System.nanoTime() - time1) / 1000000 + " ms");
    time1 = System.nanoTime();

    int countTS1 = 120;
    int countTS2 = 60;
    int countMo = (new GregorianCalendar()).get(GregorianCalendar.MONTH) + 1;
    int countAll = 0;
    // Objects for the while-loop
    Random rand = new Random();
    GregorianCalendar date;
    int runs;
    boolean tr1;
    int count;
    // ---
    while (countTS1 != 0 || countTS2 != 0) {
        countAll++;
        date = new GregorianCalendar(2009, countAll % countMo, 1);
        runs = 0;
        tr1 = false;
        count = 0;
        if (rand.nextInt(2) == 0 && countTS1 != 0) {
            count = countTS1;
            tr1 = true;
        } else if (countTS2 != 0) {
            count = countTS2;
        }
        if (count >= 10) {
            runs = rand.nextInt(10) + 1;
        } else if (count != 0) {
            runs = rand.nextInt(count) + 1;
        }
        // Authorizing the investigator for upcoming randomization
        AnonymousAuthenticationToken at = tr1
                ? new AnonymousAuthenticationToken("anonymousUser", userLInv,
                        new ArrayList<GrantedAuthority>(userLInv.getAuthorities()))
                : new AnonymousAuthenticationToken("anonymousUser", userLInv2,
                        new ArrayList<GrantedAuthority>(userLInv2.getAuthorities()));
        SecurityContextHolder.getContext().setAuthentication(at);
        SecurityContextHolder.getContext().getAuthentication().setAuthenticated(true);
        // ---
        for (int i = 0; i < runs; i++) {
            initRandBS(trial, date, rand);
            if (tr1) {
                countTS1--;
            } else {
                countTS2--;
            }
        }

    }
    System.out.println("added trial subjects: " + (System.nanoTime() - time1) / 1000000 + " ms");
}

From source file:org.n52.geoar.data.opensearch.OpenSearchLocalSource.java

public static Calendar stringToCalendar(String timeString) {
    Locale locale = Locale.GERMAN;
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", locale);
    try {//from w w  w. j  ava  2s . c  o  m
        Date d = format.parse(timeString);
        Calendar c = new GregorianCalendar();
        c.setTime(d);

        return c;
    } catch (ParseException e) {
        return null;
    }
}

From source file:org.efaps.esjp.accounting.util.data.ConSis.java

protected List<Account> readAccounts4SaldoConcar(final File _file) throws IOException, ParseException {
    final List<Account> ret = new ArrayList<>();
    final BufferedReader in = new BufferedReader(new FileReader(_file));
    final CSVReader reader = new CSVReader(in);
    final List<String[]> rows = reader.readAll();
    reader.close();//from  w  w  w.j a v a  2 s . c om
    final Pattern accPattern = Pattern.compile("^[\\d ]*");
    final DecimalFormat formater = (DecimalFormat) NumberFormat.getInstance(Locale.GERMAN);
    formater.setParseBigDecimal(true);
    //        final DecimalFormatSymbols frmSym = DecimalFormatSymbols.getInstance();
    //        frmSym.setDecimalSeparator(",".toCharArray()[0]);
    //        frmSym.setPatternSeparator(".".toCharArray()[0]);
    //        formater.setDecimalFormatSymbols(frmSym);

    for (final String[] row : rows) {
        final String accStr = row[0];
        if (!accStr.isEmpty() && accPattern.matcher(accStr).matches()) {
            final Account acc = new Account();
            ret.add(acc);
            acc.setName(accStr.trim());
            final String amountMEDebit = row[10];
            final String amountMECredit = row[11];
            final String amountMNDebit = row[12];
            final String amountMNCredit = row[13];
            if (!amountMEDebit.isEmpty()) {
                acc.setAmountME(((BigDecimal) formater.parse(amountMEDebit)).negate());
            }
            if (!amountMECredit.isEmpty()) {
                acc.setAmountME((BigDecimal) formater.parse(amountMECredit));
            }
            if (!amountMNDebit.isEmpty()) {
                acc.setAmountMN(((BigDecimal) formater.parse(amountMNDebit)).negate());
            }
            if (!amountMNCredit.isEmpty()) {
                acc.setAmountMN((BigDecimal) formater.parse(amountMNCredit));
            }
            ConSis.LOG.info("Read Account {} - Rate: {}", acc, acc.getRate());
        }
    }
    return ret;
}

From source file:org.yccheok.jstock.gui.Utils.java

/**
 * Returns true if there are specified language files designed for this
 * locale. As in Java, when there are no specified language files for a 
 * locale, a default language file will be used.
 * /*from www .  j  a  va 2 s.c o m*/
 * @param locale the locale
 * @return true if there are specified language files designed for this
 * locale
 */
public static boolean hasSpecifiedLanguageFile(Locale locale) {
    // Please revise Statement's construct code, when adding in new language.
    // So that its language guessing algorithm will work as it is.        
    if (Utils.isTraditionalChinese(locale)) {
        return true;
    } else if (Utils.isSimplifiedChinese(locale)) {
        return true;
    } else if (locale.getLanguage().equals(Locale.GERMAN.getLanguage())) {
        return true;
    } else if (locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) {
        return true;
    } else if (locale.getLanguage().equals(Locale.ITALIAN.getLanguage())) {
        return true;
    } else if (locale.getLanguage().equals(Locale.FRENCH.getLanguage())) {
        return true;
    }
    return false;
}

From source file:software.coolstuff.springframework.owncloud.service.impl.rest.OwncloudRestResourceServiceTest.java

@Override
protected void prepare_list_OK(URI searchPath, List<OwncloudTestResourceImpl> expectedOwncloudResources)
        throws Exception {
    List<DavResource> expectedDavResources = expectedOwncloudResources.stream()
            .filter(owncloudResource -> !StringUtils.equals(owncloudResource.getName(), ".."))
            .map(owncloudResource -> createDavResourceFrom(owncloudResource, Locale.GERMAN))
            .collect(Collectors.toList());
    Mockito.when(sardine.list(getResourcePath(searchPath))).thenReturn(expectedDavResources);

    if (isNotRoot(searchPath) && properties.getResourceService().isAddRelativeDownPath()) {
        expectedOwncloudResources.stream()
                .filter(owncloudResource -> StringUtils.equals(owncloudResource.getName(), ".."))
                .forEach(owncloudResource -> {
                    try {
                        DavResource superDavResource = createDavResourceFrom(owncloudResource, Locale.GERMAN);
                        Mockito.when(sardine.list(getResourcePath(URI.create("/directory/")), 0))
                                .thenReturn(Lists.newArrayList(superDavResource));
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }//from w  ww  . java 2 s  .  c  o  m
                });
    }
}

From source file:org.olat.user.restapi.UserVOFactory.java

/**
 * Allow the date to be in the localized form or not
 * @param value/*w w  w  . j a va  2 s . com*/
 * @param handler
 * @param locale
 * @return
 */
public static final String formatDbDate(String value, Locale locale) {
    if (!StringHelper.containsNonWhitespace(value)) {
        return value;
    }

    boolean raw = true;
    for (int i = 0; i < value.length(); i++) {
        if (!Character.isDigit(value.charAt(i))) {
            raw = false;
            break;
        }
    }

    if (raw) {
        return value;
    }
    try {
        DateFormat outFormater = new SimpleDateFormat("yyyyMMdd", Locale.GERMAN);
        DateFormat inFormater = DateFormat.getDateInstance(DateFormat.SHORT, locale);
        Date date = inFormater.parse(value);
        value = outFormater.format(date);
    } catch (ParseException e) {
        /* silently failed */
    }
    return value;
}