Search in sources :

Example 81 with DateFormatSymbols

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;
}
Also used : DateFormatSymbols(java.text.DateFormatSymbols) Resources(android.content.res.Resources)

Example 82 with DateFormatSymbols

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));
}
Also used : InOrder(org.mockito.InOrder) DateFormatSymbols(java.text.DateFormatSymbols) Test(org.junit.Test)

Example 83 with DateFormatSymbols

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);
    }
}
Also used : TimeZone(java.util.TimeZone) ValueEval(org.apache.poi.ss.formula.eval.ValueEval) StringEval(org.apache.poi.ss.formula.eval.StringEval) DateFormatSymbols(java.text.DateFormatSymbols) SimpleDateFormat(java.text.SimpleDateFormat) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 84 with DateFormatSymbols

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);
}
Also used : DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) DateFormatSymbols(java.text.DateFormatSymbols) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 85 with DateFormatSymbols

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;
}
Also used : DateFormatSymbols(java.text.DateFormatSymbols) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

DateFormatSymbols (java.text.DateFormatSymbols)90 SimpleDateFormat (java.text.SimpleDateFormat)30 Date (java.util.Date)23 Locale (java.util.Locale)15 Resources (android.content.res.Resources)12 ArrayList (java.util.ArrayList)11 View (android.view.View)9 TextView (android.widget.TextView)8 OnClickListener (android.view.View.OnClickListener)6 Calendar (java.util.Calendar)6 GregorianCalendar (java.util.GregorianCalendar)6 RelativeLayout (android.widget.RelativeLayout)5 Test (org.junit.Test)5 LayoutParams (android.app.ActionBar.LayoutParams)4 Typeface (android.graphics.Typeface)4 List (java.util.List)4 TypedArray (android.content.res.TypedArray)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectInputStream (java.io.ObjectInputStream)3