use of com.ibm.icu.text.SimpleDateFormat in project error-prone by google.
the class MisusedWeekYearPositiveCases2 method testApplyPatternAndApplyLocalizedPattern.
void testApplyPatternAndApplyLocalizedPattern() {
SimpleDateFormat sdf = new SimpleDateFormat();
// BUG: Diagnostic contains: sdf.applyPattern("yyyy-MM-dd")
sdf.applyPattern("YYYY-MM-dd");
// BUG: Diagnostic contains:
sdf.applyLocalizedPattern("YYYY-MM-dd");
}
use of com.ibm.icu.text.SimpleDateFormat in project eclipse.platform.text by eclipse.
the class GlobalTemplateVariablesDateTest method testComplexLocale.
@Test
public void testComplexLocale() throws Exception {
TemplateBuffer buffer = fTranslator.translate("France ${d:date('EEEE dd MMMM YYYY', 'fr_FR')} and Germany ${p:date('EEEE dd. MMMM YYYY', 'de_DE')}");
fType.resolve(buffer, fContext);
StringBuffer expected = new StringBuffer();
expected.append("France ");
expected.append(new SimpleDateFormat("EEEE dd MMMM YYYY", ULocale.FRANCE).format(new java.util.Date()));
expected.append(" and Germany ");
expected.append(new SimpleDateFormat("EEEE dd. MMMM YYYY", ULocale.GERMANY).format(new java.util.Date()));
assertBufferStringAndVariables(expected.toString(), buffer);
}
use of com.ibm.icu.text.SimpleDateFormat in project eclipse.platform.text by eclipse.
the class GlobalTemplateVariablesDateTest method testOneParameter.
@Test
public void testOneParameter() throws Exception {
TemplateBuffer buffer = fTranslator.translate("This format ${d:date('dd MMM YYYY')} and not ${p:date('YYYY-MM-dd')}");
fType.resolve(buffer, fContext);
StringBuffer expected = new StringBuffer();
expected.append("This format ");
expected.append(new SimpleDateFormat("dd MMM YYYY").format(new java.util.Date()));
expected.append(" and not ");
expected.append(new SimpleDateFormat("YYYY-MM-dd").format(new java.util.Date()));
assertBufferStringAndVariables(expected.toString(), buffer);
}
use of com.ibm.icu.text.SimpleDateFormat in project eclipse.platform.text by eclipse.
the class GlobalTemplateVariablesDateTest method testSimpleLocale.
@Test
public void testSimpleLocale() throws Exception {
TemplateBuffer buffer = fTranslator.translate("From ${d:date('dd MMM YYYY', 'fr')} to ${d}");
fType.resolve(buffer, fContext);
StringBuffer expected = new StringBuffer();
expected.append("From ");
expected.append(new SimpleDateFormat("dd MMM YYYY", ULocale.FRENCH).format(new java.util.Date()));
expected.append(" to ");
expected.append(new SimpleDateFormat("dd MMM YYYY", ULocale.FRENCH).format(new java.util.Date()));
assertBufferStringAndVariables(expected.toString(), buffer);
}
use of com.ibm.icu.text.SimpleDateFormat in project eclipse.platform.text by eclipse.
the class GlobalTemplateVariablesDateTest method testInvalidLocale.
@Test
public void testInvalidLocale() throws Exception {
TemplateBuffer buffer = fTranslator.translate("Today is ${d:date('YYYY-MM-dd', 'this_invalid_locale')}!");
fType.resolve(buffer, fContext);
StringBuffer expected = new StringBuffer();
expected.append("Today is ");
expected.append(new SimpleDateFormat("YYYY-MM-dd", new ULocale("this_invalid_locale")).format(new java.util.Date()));
expected.append("!");
assertBufferStringAndVariables(expected.toString(), buffer);
}
Aggregations