use of java.text.DateFormatSymbols in project HoloEverywhere by Prototik.
the class AmPmCirclesView method initialize.
public void initialize(int amOrPm) {
if (mIsInitialized) {
Log.e(TAG, "AmPmCirclesView may only be initialized once.");
return;
}
Resources res = getContext().getResources();
mPaint.setTypeface(FontLoader.ROBOTO_REGULAR.getTypeface(getContext()));
mPaint.setAntiAlias(true);
mPaint.setTextAlign(Align.CENTER);
mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.time_circle_radius_multiplier));
mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.time_ampm_circle_radius_multiplier));
String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
mAmText = amPmTexts[0];
mPmText = amPmTexts[1];
setAmOrPm(amOrPm);
mAmOrPmPressed = -1;
mIsInitialized = true;
}
use of java.text.DateFormatSymbols in project CompactCalendarView by SundeepK.
the class CompactCalendarControllerTest method testItAbbreviatesDayNames.
@Test
public void testItAbbreviatesDayNames() {
//simulate Feb month
when(calendar.get(Calendar.DAY_OF_WEEK)).thenReturn(1);
when(calendar.get(Calendar.MONTH)).thenReturn(1);
when(calendar.getActualMaximum(Calendar.DAY_OF_MONTH)).thenReturn(28);
//set grow progress so that it simulates the calendar being open
underTest.setGrowProgress(1000);
underTest.setLocale(TimeZone.getTimeZone("Europe/Paris"), Locale.FRANCE);
//reset because invalidate is called
reset(canvas);
underTest.setUseWeekDayAbbreviation(true);
//reset because invalidate is called
reset(canvas);
underTest.drawMonth(canvas, calendar, 0);
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(Locale.FRANCE);
String[] dayNames = dateFormatSymbols.getShortWeekdays();
InOrder inOrder = inOrder(canvas);
inOrder.verify(canvas).drawText(eq(dayNames[2]), anyInt(), anyInt(), eq(paint));
inOrder.verify(canvas).drawText(eq(dayNames[3]), anyInt(), anyInt(), eq(paint));
inOrder.verify(canvas).drawText(eq(dayNames[4]), anyInt(), anyInt(), eq(paint));
inOrder.verify(canvas).drawText(eq(dayNames[5]), anyInt(), anyInt(), eq(paint));
inOrder.verify(canvas).drawText(eq(dayNames[6]), anyInt(), anyInt(), eq(paint));
inOrder.verify(canvas).drawText(eq(dayNames[7]), anyInt(), anyInt(), eq(paint));
inOrder.verify(canvas).drawText(eq(dayNames[1]), anyInt(), anyInt(), eq(paint));
}
use of java.text.DateFormatSymbols in project poi by apache.
the class TestText method testTextWithDateFormatSecondArg.
@Test
public void testTextWithDateFormatSecondArg() {
TimeZone userTZ = LocaleUtil.getUserTimeZone();
LocaleUtil.setUserTimeZone(TimeZone.getTimeZone("CET"));
try {
// Test with Java style M=Month
ValueEval numArg = new NumberEval(321.321);
ValueEval formatArg = new StringEval("dd:MM:yyyy hh:mm:ss");
ValueEval[] args = { numArg, formatArg };
ValueEval result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
ValueEval testResult = new StringEval("16:11:1900 07:42:14");
assertEquals(testResult.toString(), result.toString());
// Excel also supports "m before h is month"
formatArg = new StringEval("dd:mm:yyyy hh:mm:ss");
args[1] = formatArg;
result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
testResult = new StringEval("16:11:1900 07:42:14");
assertEquals(testResult.toString(), result.toString());
// this line is intended to compute how "November" would look like in the current locale
// update: now the locale will be (if not set otherwise) always Locale.getDefault() (see LocaleUtil)
DateFormatSymbols dfs = DateFormatSymbols.getInstance(LocaleUtil.getUserLocale());
SimpleDateFormat sdf = new SimpleDateFormat("MMMM", dfs);
sdf.setTimeZone(LocaleUtil.getUserTimeZone());
String november = sdf.format(LocaleUtil.getLocaleCalendar(2015, 10, 1).getTime());
// Again with Java style
formatArg = new StringEval("MMMM dd, yyyy");
args[1] = formatArg;
result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
testResult = new StringEval(november + " 16, 1900");
assertEquals(testResult.toString(), result.toString());
// And Excel style
formatArg = new StringEval("mmmm dd, yyyy");
args[1] = formatArg;
result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
testResult = new StringEval(november + " 16, 1900");
assertEquals(testResult.toString(), result.toString());
} finally {
LocaleUtil.setUserTimeZone(userTZ);
}
}
use of java.text.DateFormatSymbols in project tika by apache.
the class RFC822ParserTest method testDate.
private void testDate(String dateString, String expected) throws Exception {
Date parsedDate = getDate(dateString);
assertNotNull("couldn't parse " + dateString, parsedDate);
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", new DateFormatSymbols(Locale.US));
String parsedDateString = df.format(parsedDate);
assertEquals("failed to match: " + dateString, expected, parsedDateString);
}
use of java.text.DateFormatSymbols in project tika by apache.
the class MailContentHandler method createDateFormat.
private static DateFormat createDateFormat(String format, TimeZone timezone, boolean isLenient) {
SimpleDateFormat sdf = new SimpleDateFormat(format, new DateFormatSymbols(Locale.US));
if (timezone != null) {
sdf.setTimeZone(timezone);
}
sdf.setLenient(isLenient);
return sdf;
}
Aggregations