java.util.Locale#GERMAN源码实例Demo

下面列出了java.util.Locale#GERMAN 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: projectforge-webapp   文件: DateHolderTest.java
@Test
public void getBeginAndEndOfMonth()
{
  DateHolder dateHolder = new DateHolder(DatePrecision.DAY, DateHelper.UTC, Locale.GERMAN);
  dateHolder.setDate(1970, Calendar.NOVEMBER, 21, 4, 50, 23);
  assertEquals("1970-11-21 00:00:00.000", DateHelper.getForTestCase(dateHolder.getDate()));
  dateHolder.setBeginOfMonth();
  assertEquals("1970-11-01 00:00:00.000", DateHelper.getForTestCase(dateHolder.getDate()));
  dateHolder.setDate(1970, Calendar.NOVEMBER, 21, 4, 50, 23);
  assertEquals("1970-11-21 00:00:00.000", DateHelper.getForTestCase(dateHolder.getDate()));
  dateHolder.setEndOfMonth();
  assertEquals("1970-11-30 23:59:59.999", DateHelper.getForTestCase(dateHolder.getDate()));

  dateHolder = new DateHolder(DatePrecision.DAY, DateHelper.UTC, Locale.GERMAN);
  dateHolder.setDate(2007, Calendar.JANUARY, 21, 4, 50, 23);
  dateHolder.setEndOfMonth();
  assertEquals("2007-01-31 23:59:59.999", DateHelper.getForTestCase(dateHolder.getDate()));
  dateHolder.setDate(2007, Calendar.FEBRUARY, 1, 4, 50, 23);
  dateHolder.setEndOfMonth();
  assertEquals("2007-02-28 23:59:59.999", DateHelper.getForTestCase(dateHolder.getDate()));
  dateHolder.setDate(2004, Calendar.FEBRUARY, 1, 4, 50, 23);
  dateHolder.setEndOfMonth();
  assertEquals("2004-02-29 23:59:59.999", DateHelper.getForTestCase(dateHolder.getDate()));
}
 
源代码2 项目: olat   文件: UserVOFactory.java
/**
 * Allow the date to be in the raw form (yyyyMMdd) or translated to be translated
 * 
 * @param value
 * @param handler
 * @param locale
 * @return
 */
public static final String parseDate(String value, final 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) {
        try {
            final DateFormat formater = new SimpleDateFormat("yyyyMMdd", Locale.GERMAN);
            final Date date = formater.parse(value);
            value = Formatter.getInstance(locale).formatDate(date);
        } catch (final ParseException e) {
            /* silently failed */
        }
    }
    return value;
}
 
@Test
public void germanInitialVICMetricTest() {
    InitialVoiceInstructionConfig configMetric = new InitialVoiceInstructionConfig(FOR_HIGHER_DISTANCE_PLURAL.metric, trMap, mtrMap, Locale.GERMAN, 4250, 250, DistanceUtils.Unit.METRIC);

    compareVoiceInstructionValues(
            4000,
            "Dem Straßenverlauf folgen für 4 Kilometer",
            configMetric.getConfigForDistance(5000, "abbiegen", " dann")
    );

    compareVoiceInstructionValues(
            4000,
            "Dem Straßenverlauf folgen für 4 Kilometer",
            configMetric.getConfigForDistance(4500, "abbiegen", " dann")
    );
}
 
源代码4 项目: development   文件: PriceConverterTest.java
@Test
public void testParse_MaximumFractionDigits_DE() throws Exception {
    PriceConverter converter = new PriceConverter(Locale.GERMAN);
    Assert.assertEquals(Locale.GERMAN, converter.getActiveLocale());

    BigDecimal d = converter
            .parse("50.000,11111111111111111111111111111111111111111111111111");
    assertEquals(new BigDecimal(
            "50000.11111111111111111111111111111111111111111111111111"), d);
}
 
源代码5 项目: development   文件: PriceConverterTest.java
@Test
public void testParse_GermanLocaleOwnOutput() throws Exception {
    PriceConverter converter = new PriceConverter(Locale.GERMAN);
    Assert.assertEquals(Locale.GERMAN, converter.getActiveLocale());
    long price = 50L;
    String valueToDisplay = converter.getValueToDisplay(new BigDecimal(
            price), true);
    BigDecimal valueToStore = converter.parse(valueToDisplay);
    checkEquals("50.00", valueToStore);
}
 
源代码6 项目: open-rmbt   文件: RMBTMainActivity.java
/**
 * 
 * @param toFile
 */
public void redirectSystemOutput(boolean toFile) {
    try {
    	if (toFile) {
    		Log.i(DEBUG_TAG,"redirecting sysout to file");
    		//Redirecting console output and runtime exceptions to file (System.out.println)
    		File f = new File(Environment.getExternalStorageDirectory(), "qosdebug");
    		if (!f.exists()) {
    			f.mkdir();
    		}
        
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd", Locale.GERMAN);
    		//PrintStream fileStream = new PrintStream(new File(f, sdf.format(new Date()) + ".txt"));
    		PrintStream fileStream = new DebugPrintStream(new File(f, sdf.format(new Date()) + ".txt"));
         
    		//System.setOut(fileStream);
            System.setErr(fileStream);
    	}
    	else {        		
    		//Redirecting console output and runtime exceptions to default output stream
            //System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
            //System.setErr(new PrintStream(new FileOutputStream(FileDescriptor.err)));
            //Log.i(DEBUG_TAG,"redirecting sysout to default");
    	}
    }
    catch (Exception e) {
    	e.printStackTrace();
    }
}
 
源代码7 项目: newsleak   文件: SentenceCleaner.java
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
	super.initialize(context);
	log = context.getLogger();
	log.setLevel(Level.ALL);
	dfs = new DateFormatSymbols(Locale.GERMAN);
	monthNames = new HashSet<String>(Arrays.asList(dfs.getMonths()));
}
 
源代码8 项目: hottub   文件: TestChronoField.java
@DataProvider(name = "localeList")
Locale[] data_localeList() {
    return new Locale[] {
            Locale.US,
            Locale.GERMAN,
            Locale.JAPAN,
            Locale.ROOT,
    };
}
 
源代码9 项目: buck   文件: TestResultFormatterTest.java
@Test
public void shouldUseDecimalCommaForGerman() {
  TestResultFormatter formatter =
      new TestResultFormatter(
          new Ansi(false),
          Verbosity.COMMANDS,
          TestResultSummaryVerbosity.of(false, false),
          Locale.GERMAN,
          Optional.of(logPath),
          TimeZone.getTimeZone("America/Los_Angeles"));

  TestCaseSummary summary =
      new TestCaseSummary(
          "com.example.FooTest",
          ImmutableList.of(
              new TestResultSummary(
                  "com.example.FooTest",
                  "successTest",
                  ResultType.SUCCESS,
                  12300,
                  /*message*/ null,
                  /*stacktrace*/ null,
                  "good stdout",
                  "good stderr")));
  TestResults results = FakeTestResults.of(ImmutableList.of(summary));
  ImmutableList.Builder<String> builder = ImmutableList.builder();

  formatter.reportResult(builder, results);

  assertEquals(
      "PASS     12,3s  1 Passed   0 Skipped   0 Failed   com.example.FooTest", toString(builder));
}
 
源代码10 项目: projectforge-webapp   文件: AbstractBaseDOTest.java
private FooDO createFooDO(final int createdDayOfMonth, final int lastUpdateDateOfMonth, final boolean deleted, final boolean testBoolean, final String testString)
{
  final FooDO obj = new FooDO();
  final DateHolder dateHolder = new DateHolder(DatePrecision.SECOND, Locale.GERMAN);
  obj.setId(42);
  dateHolder.setDate(1970, Calendar.NOVEMBER, createdDayOfMonth, 4, 50, 0);
  obj.setCreated(dateHolder.getDate());
  dateHolder.setDate(1970, Calendar.NOVEMBER, lastUpdateDateOfMonth, 4, 50, 0);
  obj.setLastUpdate(dateHolder.getDate());
  obj.setDeleted(deleted);
  obj.setTestBoolean(testBoolean);
  obj.setTestString(testString);
  return obj;
}
 
源代码11 项目: otroslogviewer   文件: JulSimpleFormatterParser.java
@Override
public void initParsingContext(ParsingContext parsingContext) {
  SimpleDateFormat[] datePatterns = {new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH),
    new SimpleDateFormat("MMM d, yyyy h:mm:ss a", Locale.ENGLISH), new SimpleDateFormat("dd.MM.yyyy HH:mm:ss", Locale.GERMAN),
    new SimpleDateFormat("dd-MM-yyyy HH:mm:ss", new Locale("en")), new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss", new Locale("en")),
    new SimpleDateFormat("dd MMM yyyy HH:mm:ss", new Locale("fr"))
  };
  parsingContext.getCustomConextProperties().put(DATE_PATTERNS, datePatterns);

}
 
源代码12 项目: citeproc-java   文件: SmartQuotesTest.java
/**
 * Similar to {@link #apply()} but with German quotation marks
 */
@Test
public void german() {
    SmartQuotes sq = new SmartQuotes("\u201a", "\u2018", "\u201e", "\u201c", Locale.GERMAN);

    assertEquals("\u201etest\u201c", sq.apply("\"test\""));
    assertEquals("Der\u2014 \u201eTest\u201c", sq.apply("Der\u2014 \"Test\""));
    assertEquals("\u201atest\u2018", sq.apply("'test'"));
    assertEquals("Er kann\u2019s", sq.apply("Er kann's"));
    assertEquals("Marshiness von \u2018Ammercloth\u2019s",
            sq.apply("Marshiness von 'Ammercloth's"));
    assertEquals("\u201995", sq.apply("'95"));
    assertEquals("\u2034", sq.apply("'''"));
    assertEquals("\u2033", sq.apply("''"));
    assertEquals("\u201eBesser als ein 6\u20325\u2033 Wal.\u201c",
            sq.apply("\"Besser als ein 6'5\" Wal.\""));
    assertEquals("\u201eIch hab\u2019s auf \u201a#1\u2018 gesetzt!\u201c - Der 12\u2033 Schaumstofffinger von \u201993",
            sq.apply("\"Ich hab's auf '#1' gesetzt!\" - Der 12\" Schaumstofffinger von '93"));
    assertEquals("\u201eSag \u201awas?\u2018\u201c sagt der Mitarbeiter der Mill\u2019s Pet Barn.",
            sq.apply("\"Sag 'was?'\" sagt der Mitarbeiter der Mill's Pet Barn."));
    assertEquals("\u201eQuote?\u201c: Beschreibung",
            sq.apply("\"Quote?\": Beschreibung"));
    assertEquals("\u201aQuo Te?\u2018: Beschreibung",
            sq.apply("'Quo Te?': Beschreibung"));
    assertEquals("\u201eDe Poesjes van Kevin?\u201c: Irgendwas, irgendwas",
            sq.apply("\"De Poesjes van Kevin?\": Irgendwas, irgendwas"));
    assertEquals("Und dann platze es aus ihr heraus: \u201eIch dachte, du sagtest: \u201aIch mag keine 80er-Musik\u2018?\u201c",
            sq.apply("Und dann platze es aus ihr heraus: \"Ich dachte, du sagtest: 'Ich mag keine 80er-Musik'?\""));

    assertEquals("\u201985 war ein gutes Jahr. Die ganzen 80er waren so.",
            sq.apply("'85 war ein gutes Jahr. Die ganzen 80er waren so."));
}
 
源代码13 项目: projectforge-webapp   文件: DateHolderTest.java
@Test
public void ensurePrecision()
{
  final DateHolder dateHolder = new DateHolder(DatePrecision.DAY, DateHelper.UTC, Locale.GERMAN);
  assertPrecision("1970-11-21 00:00:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 50, 23);
  dateHolder.setPrecision(DatePrecision.HOUR_OF_DAY);
  assertPrecision("1970-11-21 04:00:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 50, 23);
  dateHolder.setPrecision(DatePrecision.MINUTE);
  assertPrecision("1970-11-21 04:50:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 50, 23);
  dateHolder.setPrecision(DatePrecision.MINUTE_15);
  assertPrecision("1970-11-21 04:00:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 00, 00);
  assertPrecision("1970-11-21 04:00:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 7, 59);
  assertPrecision("1970-11-21 04:15:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 8, 00);
  assertPrecision("1970-11-21 04:15:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 15, 00);
  assertPrecision("1970-11-21 04:15:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 22, 59);
  assertPrecision("1970-11-21 04:30:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 23, 00);
  assertPrecision("1970-11-21 04:30:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 30, 00);
  assertPrecision("1970-11-21 04:30:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 37, 59);
  assertPrecision("1970-11-21 04:45:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 38, 00);
  assertPrecision("1970-11-21 04:45:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 45, 00);
  assertPrecision("1970-11-21 04:45:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 52, 59);
  assertPrecision("1970-11-21 05:00:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 53, 00);
  dateHolder.setPrecision(DatePrecision.MINUTE_5);
  assertPrecision("1970-11-21 04:00:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 02, 59);
  assertPrecision("1970-11-21 04:05:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 03, 00);
  assertPrecision("1970-11-21 04:50:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 48, 00);
  assertPrecision("1970-11-21 04:50:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 52, 59);
  assertPrecision("1970-11-21 04:55:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 53, 00);
  assertPrecision("1970-11-21 04:55:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 57, 59);
  assertPrecision("1970-11-21 05:00:00.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 58, 00);
  dateHolder.setPrecision(DatePrecision.SECOND);
  assertPrecision("1970-11-21 04:50:23.000", dateHolder, 1970, Calendar.NOVEMBER, 21, 4, 50, 23);
}
 
源代码14 项目: projectforge-webapp   文件: TimePeriodTest.java
@Test
public void testTimePeriod()
{
  final DateHolder date1 = new DateHolder(new Date(), DatePrecision.MINUTE, Locale.GERMAN);
  date1.setDate(1970, Calendar.NOVEMBER, 21, 0, 0, 0);

  final DateHolder date2 = new DateHolder(new Date(), DatePrecision.MINUTE, Locale.GERMAN);
  date2.setDate(1970, Calendar.NOVEMBER, 21, 10, 0, 0);

  TimePeriod timePeriod = new TimePeriod(date1.getDate(), date2.getDate());
  assertResultArray(new int[] {0, 10, 0}, timePeriod.getDurationFields());
  assertResultArray(new int[] {1, 2, 0}, timePeriod.getDurationFields(8));

  date2.setDate(1970, Calendar.NOVEMBER, 22, 0, 0, 0);
  timePeriod = new TimePeriod(date1.getDate(), date2.getDate());
  assertResultArray(new int[] {1, 0, 0}, timePeriod.getDurationFields());
  assertResultArray(new int[] {3, 0, 0}, timePeriod.getDurationFields(8));
  assertResultArray(new int[] {0, 24, 0}, timePeriod.getDurationFields(8, 25));
  assertResultArray(new int[] {3, 0, 0}, timePeriod.getDurationFields(8, 24));

  date2.setDate(1970, Calendar.NOVEMBER, 21, 23, 59, 59);
  timePeriod = new TimePeriod(date1.getDate(), date2.getDate());
  assertResultArray(new int[] {0, 23, 59}, timePeriod.getDurationFields());
  assertResultArray(new int[] {2, 7, 59}, timePeriod.getDurationFields(8));
  assertResultArray(new int[] {0, 23, 59}, timePeriod.getDurationFields(8, 24));
  assertResultArray(new int[] {2, 7, 59}, timePeriod.getDurationFields(8, 22));

  date2.setDate(1970, Calendar.NOVEMBER, 23, 5, 30, 0);
  timePeriod = new TimePeriod(date1.getDate(), date2.getDate());
  assertResultArray(new int[] {2, 5, 30}, timePeriod.getDurationFields());
  assertResultArray(new int[] {6, 5, 30}, timePeriod.getDurationFields(8));
  assertResultArray(new int[] {0, 53, 30}, timePeriod.getDurationFields(8, 54));
  assertResultArray(new int[] {6, 5, 30}, timePeriod.getDurationFields(8, 53));
}
 
源代码15 项目: projectforge-webapp   文件: QueryFilter.java
/**
 * Locale is needed for lucene stemmers (hibernate search).
 * @return
 */
public Locale getLocale()
{
  if (locale == null) {
    return Locale.GERMAN;
  }
  return locale;
}
 
源代码16 项目: jdk8u-dev-jdk   文件: TestChronoField.java
@DataProvider(name = "localeList")
Locale[] data_localeList() {
    return new Locale[] {
            Locale.US,
            Locale.GERMAN,
            Locale.JAPAN,
            Locale.ROOT,
    };
}
 
源代码17 项目: super-csv   文件: ParseSqlTimeTest.java
/**
 * Tests construction (using the Locale constructor) with a null date format (should throw an Exception).
 */
@Test(expected = NullPointerException.class)
public void testLocaleConstructorWithNullDateFormat() {
	new ParseSqlTime(null, false, Locale.GERMAN);
}
 
源代码18 项目: jdk8u60   文件: MessageCatalog.java
private Locale getLocale(String localeName) {
    String language, country;
    int index;

    index = localeName.indexOf('_');
    if (index == -1) {
        //
        // Special case the builtin JDK languages
        //
        if (localeName.equals("de"))
            return Locale.GERMAN;
        if (localeName.equals("en"))
            return Locale.ENGLISH;
        if (localeName.equals("fr"))
            return Locale.FRENCH;
        if (localeName.equals("it"))
            return Locale.ITALIAN;
        if (localeName.equals("ja"))
            return Locale.JAPANESE;
        if (localeName.equals("ko"))
            return Locale.KOREAN;
        if (localeName.equals("zh"))
            return Locale.CHINESE;

        language = localeName;
        country = "";
    } else {
        if (localeName.equals("zh_CN"))
            return Locale.SIMPLIFIED_CHINESE;
        if (localeName.equals("zh_TW"))
            return Locale.TRADITIONAL_CHINESE;

        //
        // JDK also has constants for countries:  en_GB, en_US, en_CA,
        // fr_FR, fr_CA, de_DE, ja_JP, ko_KR.  We don't use those.
        //
        language = localeName.substring(0, index);
        country = localeName.substring(index + 1);
    }

    return new Locale(language, country);
}
 
源代码19 项目: openjdk-jdk8u   文件: MessageCatalog.java
private Locale getLocale(String localeName) {
    String language, country;
    int index;

    index = localeName.indexOf('_');
    if (index == -1) {
        //
        // Special case the builtin JDK languages
        //
        if (localeName.equals("de"))
            return Locale.GERMAN;
        if (localeName.equals("en"))
            return Locale.ENGLISH;
        if (localeName.equals("fr"))
            return Locale.FRENCH;
        if (localeName.equals("it"))
            return Locale.ITALIAN;
        if (localeName.equals("ja"))
            return Locale.JAPANESE;
        if (localeName.equals("ko"))
            return Locale.KOREAN;
        if (localeName.equals("zh"))
            return Locale.CHINESE;

        language = localeName;
        country = "";
    } else {
        if (localeName.equals("zh_CN"))
            return Locale.SIMPLIFIED_CHINESE;
        if (localeName.equals("zh_TW"))
            return Locale.TRADITIONAL_CHINESE;

        //
        // JDK also has constants for countries:  en_GB, en_US, en_CA,
        // fr_FR, fr_CA, de_DE, ja_JP, ko_KR.  We don't use those.
        //
        language = localeName.substring(0, index);
        country = localeName.substring(index + 1);
    }

    return new Locale(language, country);
}
 
源代码20 项目: super-csv   文件: ParseDateTest.java
/**
 * Tests construction (using the Locale constructor) with a null date format (should throw an Exception).
 */
@Test(expected = NullPointerException.class)
public void testLocaleConstructorWithNullDateFormat() {
	new ParseDate(null, false, Locale.GERMAN);
}