Exemple #1
0
        public void TestScratch()
        {
            String[]          strMonths = { "Januari", "Pebruari", "Maret",   "April",     "Mei",
                                            "Juni",             "Juli",     "Agustus", "September", "Oktober","Nopember",
                                            "Desember" };
            String[]          strShortMonths = { "Jan", "Peb", "Mar", "Apr", "Mei", "Jun",
                                                 "Jul",          "Agt", "Sep", "Okt", "Nop", "Des" };
            String[]          strWeeks = { "", "Minggu", "Senin", "Selasa", "Rabu", "Kamis",
                                           "Jumat",     "Sabtu" };
            DateFormatSymbols dfsDate = new DateFormatSymbols(
                new ILOG.J2CsMapping.Util.Locale("id", "ID"));

            dfsDate.SetMonths(strMonths);
            dfsDate.SetShortMonths(strShortMonths);
            dfsDate.SetWeekdays(strWeeks);
            ULocale uloInd = dfsDate.GetLocale(IBM.ICU.Util.ULocale.ACTUAL_LOCALE);

            if (uloInd == null)
            {
                Errln("did not get the expected ULocale");
            }
            Logln(uloInd.ToString());
            ILOG.J2CsMapping.Util.Locale locInd = uloInd.ToLocale();
            if (locInd == null)
            {
                Errln("did not get the expected result");
            }
            Logln(locInd.ToString());
        }
Exemple #2
0
 internal override void InitializeData(DateFormatSymbols dfs)
 {
     base.InitializeData(dfs);
     if (dfs  is  ChineseDateFormatSymbols)
     {
         this.isLeapMonth = ((ChineseDateFormatSymbols)dfs).isLeapMonth;
     }
 }
Exemple #3
0
        /// <summary>
        /// Refresh month title text view when user swipe.
        /// </summary>
        protected void UpdateMonthTitleTextView()
        {
            var monthArray     = DateFormatSymbols.GetInstance(Locale.Default).GetMonths();
            var monthName      = monthArray[_month - 1];
            var monthNameTitle = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(monthName);

            var monthText = string.Concat(monthNameTitle, " ", _year);

            _monthTitleTextView.SetText(monthText, TextView.BufferType.Normal);
        }
        private void InitializeSymbols()
        {
#if ANDROID_9P
            var f = DateFormatSymbols.GetInstance(Locale);
            amDesignator = f.AmPmStrings[Java.Util.Calendar.AM];
            pmDesignator = f.AmPmStrings[Java.Util.Calendar.PM];
#else
            amDesignator = DefaultAM;
            pmDesignator = DefaultPM;
#endif
            // TODO how to get date and time separators?
            dateSeparator = DefaultDateSeparator;
            timeSeparator = DefaultTimeSeparator;
        }
        public void setUseWeekDayAbbreviation(bool useThreeLetterAbbreviation)
        {
            this.useThreeLetterAbbreviation = useThreeLetterAbbreviation;
            DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);

            string[] dayNames = dateFormatSymbols.GetShortWeekdays();
            if (dayNames == null)
            {
                throw new IllegalStateException("Unable to determine weekday names from default locale");
            }
            if (dayNames.Length != 8)
            {
                throw new IllegalStateException("Expected weekday names from default locale to be of size 7 but: "
                                                + "'" + string.Join("'", dayNames) + "', with size " + dayNames.Length + " was returned.");
            }

            if (useThreeLetterAbbreviation)
            {
                if (!shouldShowMondayAsFirstDay)
                {
                    this.dayColumnNames = new string[] { dayNames[1], dayNames[2], dayNames[3], dayNames[4], dayNames[5], dayNames[6], dayNames[7] };
                }
                else
                {
                    this.dayColumnNames = new string[] { dayNames[2], dayNames[3], dayNames[4], dayNames[5], dayNames[6], dayNames[7], dayNames[1] };
                }
            }
            else
            {
                if (!shouldShowMondayAsFirstDay)
                {
                    this.dayColumnNames = new string[] { dayNames[1].Substring(0, 1), dayNames[2].Substring(0, 1),
                                                         dayNames[3].Substring(0, 1), dayNames[4].Substring(0, 1), dayNames[5].Substring(0, 1), dayNames[6].Substring(0, 1), dayNames[7].Substring(0, 1) };
                }
                else
                {
                    this.dayColumnNames = new string[] { dayNames[2].Substring(0, 1), dayNames[3].Substring(0, 1),
                                                         dayNames[4].Substring(0, 1), dayNames[5].Substring(0, 1), dayNames[6].Substring(0, 1), dayNames[7].Substring(0, 1), dayNames[1].Substring(0, 1) };
                }
            }
        }
        public TimePicker(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
        {
            LayoutInflater inflater =
                (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);

            inflater.Inflate(Resource.Layout.time_picker_widget, this, true);


            // hour
            mHourPicker = (NumberPicker)FindViewById(Resource.Id.hour);
            mHourPicker.SetOnValueChangedListener(new OnValueChangeListener()
            {
                OnValueChanged = (NumberPicker picker, int oldVal, int newVal) =>
                {
                    // TODO Auto-generated method stub
                    mCurrentHour = newVal;
                    if (!mIs24HourView)
                    {
                        // adjust from [1-12] to [0-11] internally, with the times
                        // written "12:xx" being the start of the half-day
                        if (mCurrentHour == 12)
                        {
                            mCurrentHour = 0;
                        }
                        if (!mIsAm)
                        {
                            // PM means 12 hours later than nominal
                            mCurrentHour += 12;
                        }
                    }
                    onTimeChanged();
                }
            });

            // digits of minute
            mMinutePicker          = (NumberPicker)FindViewById(Resource.Id.minute);
            mMinutePicker.MinValue = 0;

            mMinutePicker.MaxValue = 59;
            mMinutePicker.SetFormatter(TWO_DIGIT_FORMATTER);
            mMinutePicker.SetOnValueChangedListener(new Droid.OnValueChangeListener()
            {
                OnValueChanged = (NumberPicker spinner, int oldVal, int newVal) =>
                {
                    mCurrentMinute = newVal;
                    onTimeChanged();
                }
            });


            // digits of seconds
            mSecondPicker          = (NumberPicker)FindViewById(Resource.Id.seconds);
            mSecondPicker.MinValue = 0;

            mSecondPicker.MaxValue = 59;
            mSecondPicker.SetFormatter(TWO_DIGIT_FORMATTER);
            mSecondPicker.SetOnValueChangedListener(new Droid.OnValueChangeListener()
            {
                OnValueChanged = (NumberPicker spinner, int oldVal, int newVal) =>
                {
                    mCurrentSeconds = newVal;
                    onTimeChanged();
                }
            });

            mAmPmButton = (Button)FindViewById(Resource.Id.amPm);

            // now that the hour/minute picker objects have been initialized, set
            // the hour range properly based on the 12/24 hour display mode.
            configurePickerRanges();

            // initialize to current time
            Calendar cal = Calendar.GetInstance(ULocale.English);

            setOnTimeChangedListener(NO_OP_CHANGE_LISTENER);

            // by default we're not in 24 hour mode
            setCurrentHour(cal.Get(CalendarField.HourOfDay));

            setCurrentMinute(cal.Get(CalendarField.Minute));

            setCurrentSecond(cal.Get(CalendarField.Second));

            mIsAm = (mCurrentHour < 12);


            /* Get the localized am/pm strings and use them in the spinner */
            DateFormatSymbols dfs = new DateFormatSymbols();

            string[] dfsAmPm = dfs.GetAmPmStrings();
            mAmText = dfsAmPm[Calendar.Am];
            mPmText = dfsAmPm[Calendar.Pm];
            mAmPmButton.SetText(mIsAm ? mAmText : mPmText, TextView.BufferType.Normal);
            mAmPmButton.SetOnClickListener(new OnClickListener()
            {
                Clicked = (View v) =>
                {
                    //requestFocus();
                    if (mIsAm)
                    {
                        // Currently AM switching to PM
                        if (mCurrentHour < 12)
                        {
                            mCurrentHour += 12;
                        }
                    }
                    else
                    {
                        // Currently PM switching to AM
                        if (mCurrentHour >= 12)
                        {
                            mCurrentHour -= 12;
                        }
                    }
                    mIsAm = !mIsAm;
                    mAmPmButton.SetText(mIsAm ? mAmText : mPmText, TextView.BufferType.Normal);
                    onTimeChanged();
                }
            });

            SetEnabled();
        }