Example #1
0
        public void TestYear()
        {
            // Gregorian Calendar
            IBM.ICU.Util.Calendar gCal = new IBM.ICU.Util.GregorianCalendar();
            DateTime gToday = gCal.GetTime();
            gCal.Add(IBM.ICU.Util.Calendar.MONTH, 2);
            DateTime gFuture = gCal.GetTime();
            DateFormat gDF = IBM.ICU.Text.DateFormat.GetDateInstance(gCal, IBM.ICU.Text.DateFormat.FULL);
            Logln("gregorian calendar: " + gDF.Format(gToday) + " + 2 months = "
                    + gDF.Format(gFuture));

            // Coptic Calendar
            CopticCalendar cCal = new CopticCalendar();
            DateTime cToday = cCal.GetTime();
            cCal.Add(IBM.ICU.Util.Calendar.MONTH, 2);
            DateTime cFuture = cCal.GetTime();
            DateFormat cDF = IBM.ICU.Text.DateFormat.GetDateInstance(cCal, IBM.ICU.Text.DateFormat.FULL);
            Logln("coptic calendar: " + cDF.Format(cToday) + " + 2 months = "
                    + cDF.Format(cFuture));

            // EthiopicCalendar
            EthiopicCalendar eCal = new EthiopicCalendar();
            DateTime eToday = eCal.GetTime();
            eCal.Add(IBM.ICU.Util.Calendar.MONTH, 2); // add 2 months
            eCal.SetAmeteAlemEra(false);
            DateTime eFuture = eCal.GetTime();
            DateFormat eDF = IBM.ICU.Text.DateFormat.GetDateInstance(eCal, IBM.ICU.Text.DateFormat.FULL);
            Logln("ethiopic calendar: " + eDF.Format(eToday) + " + 2 months = "
                    + eDF.Format(eFuture));
        }
Example #2
0
        protected virtual void AssertDateEquals(string description, string pattern, PlatformDate expected, PlatformDate actual)
        {
            Assert.IsNotNull(actual, description + " not null");
            DateFormat format = DateUtil.Instance(pattern);

            Assert.AreEqual(format.Format(expected), format.Format(actual), description);
        }
Example #3
0
        private void LoadCommandSummary(CommandManagementItem cmdMngItem)
        {
            //var user = _userBLL.GetById(tradeCommand.SubmitPerson);
            this.tbCommandId.Text    = string.Format("{0}", cmdMngItem.CommandId);
            this.tbFundName.Text     = cmdMngItem.FundDisplay;
            this.tbPortName.Text     = cmdMngItem.PortfolioDisplay;// string.Format("{0}--{1}", tradeCommand.PortfolioCode, tradeCommand.PortfolioName);
            this.tbSecuName.Text     = "N/A";
            this.tbPriceMode.Text    = "N/A";
            this.tbCommandPrice.Text = "N/A";
            //this.tbCommandAmount.Text = string.Format("{0}", tradeCommand.CommandNum);
            //TODO:get the deal amount
            this.tbDealAmount.Text    = "0";
            this.tbAveragePrice.Text  = "N/A";
            this.tbSubmitDate.Text    = cmdMngItem.CommandSubmitDate;
            this.tbSubmitTime.Text    = cmdMngItem.CommandSubmitTime;
            this.tbStartDate.Text     = cmdMngItem.StartDate;
            this.tbStartTime.Text     = cmdMngItem.StartTime;
            this.tbEndDate.Text       = cmdMngItem.EndDate;
            this.tbEndTime.Text       = cmdMngItem.EndTime;
            this.tbCommandStatus.Text = cmdMngItem.CommandStatus;
            this.tbEntrustStatus.Text = cmdMngItem.EntrustExecuteStatus;// CommandStatusHelper.GetEntrustName(tradeCommand.EEntrustStatus);
            this.tbDealStatus.Text    = CommandStatusHelper.GetDealName(cmdMngItem.EDealStatus);

            this.tbSubmitPerson.Text = cmdMngItem.CommandSubmitPerson;
            this.tbModifyPerson.Text = cmdMngItem.ModifyOperator;
            this.tbCancelPerson.Text = cmdMngItem.ModifyOperator;

            this.tbModifyTime.Text  = DateFormat.Format(cmdMngItem.DModifiedDate, ConstVariable.TimeFormat);
            this.tbCancelTime.Text  = DateFormat.Format(cmdMngItem.DCancelDate, ConstVariable.TimeFormat);
            this.tbNotes.Text       = cmdMngItem.Notes;
            this.tbModifyCause.Text = cmdMngItem.ModifiedCause;
            this.tbCancelCause.Text = cmdMngItem.CancelCause;
        }
        protected override void OnStart()
        {
            base.OnStart();

            //var h = new Handler(Looper.MainLooper);
            taskAction = new Action(() => {
                if (mList.Count > SIZE)
                {
                    mList.RemoveAt(0);
                }
                System.Random random = new System.Random();
                int temp             = random.Next(100);
                string time          = DateFormat.Format("mm:ss", new Date()).ToString();

                mList.Add(new ChartPoint(time, temp, temp + 10, temp + 20));

                mChart.ItemsSource = mList;

                // There is a issue on mList collection changed event handling. So we have below 4 lines code to refresh the chart.
                mChart.Series[0].Dispose();
                mChart.Series[1].Dispose();
                mChart.Series[2].Dispose();
                mChart.Invalidate();

                mHandler.PostDelayed(taskAction, 125);
            });

            mHandler.PostDelayed(taskAction, 125);
        }
Example #5
0
        /// <exception cref="System.IO.IOException"/>
        public override void CreateCheckpoint()
        {
            if (!fs.Exists(current))
            {
                // no trash, no checkpoint
                return;
            }
            Path checkpointBase;

            lock (Checkpoint)
            {
                checkpointBase = new Path(trash, Checkpoint.Format(new DateTime()));
            }
            Path checkpoint = checkpointBase;
            int  attempt    = 0;

            while (true)
            {
                try
                {
                    fs.Rename(current, checkpoint, Options.Rename.None);
                    break;
                }
                catch (FileAlreadyExistsException)
                {
                    if (++attempt > 1000)
                    {
                        throw new IOException("Failed to checkpoint trash: " + checkpoint);
                    }
                    checkpoint = checkpointBase.Suffix("-" + attempt);
                }
            }
            Log.Info("Created trash checkpoint: " + checkpoint.ToUri().GetPath());
        }
Example #6
0
        public static String getCurrentDate()
        {
            Locale loc   = new Locale("en", "us");
            Date   today = Calendar.GetInstance(loc).Time;

            return(dateFormat.Format(today));
        }
Example #7
0
        /// <summary>Build a JSON entry from the parameters.</summary>
        /// <remarks>Build a JSON entry from the parameters. This is public for testing.</remarks>
        /// <param name="writer">destination</param>
        /// <param name="loggerName">logger name</param>
        /// <param name="timeStamp">time_t value</param>
        /// <param name="level">level string</param>
        /// <param name="threadName">name of the thread</param>
        /// <param name="message">rendered message</param>
        /// <param name="ti">nullable thrown information</param>
        /// <returns>the writer</returns>
        /// <exception cref="System.IO.IOException">on any problem</exception>
        public virtual TextWriter ToJson(TextWriter writer, string loggerName, long timeStamp
                                         , string level, string threadName, string message, ThrowableInformation ti)
        {
            JsonGenerator json = factory.CreateJsonGenerator(writer);

            json.WriteStartObject();
            json.WriteStringField(Name, loggerName);
            json.WriteNumberField(Time, timeStamp);
            DateTime date = Extensions.CreateDate(timeStamp);

            json.WriteStringField(Date, dateFormat.Format(date));
            json.WriteStringField(Level, level);
            json.WriteStringField(Thread, threadName);
            json.WriteStringField(Message, message);
            if (ti != null)
            {
                //there is some throwable info, but if the log event has been sent over the wire,
                //there may not be a throwable inside it, just a summary.
                Exception thrown = ti.GetThrowable();
                string    eclass = (thrown != null) ? thrown.GetType().FullName : string.Empty;
                json.WriteStringField(ExceptionClass, eclass);
                string[] stackTrace = ti.GetThrowableStrRep();
                json.WriteArrayFieldStart(Stack);
                foreach (string row in stackTrace)
                {
                    json.WriteString(row);
                }
                json.WriteEndArray();
            }
            json.WriteEndObject();
            json.Flush();
            json.Close();
            return(writer);
        }
Example #8
0
        public List <DealFlowItem> GetDealFlow()
        {
            List <DealFlowItem> dfItems = new List <DealFlowItem>();

            var allItems             = _entrustSecurityBLL.GetAllCombine();
            var entrustedNoDealItems = allItems.Where(p => p.DealStatus == DealStatus.Completed);

            foreach (var item in entrustedNoDealItems)
            {
                DealFlowItem dfItem = new DealFlowItem
                {
                    CommandNo      = item.CommandId,
                    SecuCode       = item.SecuCode,
                    PriceType      = item.PriceType.ToString(),
                    FundNo         = item.AccountCode,
                    FundName       = item.AccountName,
                    PortfolioCode  = item.PortfolioCode,
                    PortfolioName  = item.PortfolioName,
                    EntrustPrice   = item.EntrustPrice,
                    DealAmount     = item.TotalDealAmount,
                    DealTime       = DateFormat.Format(item.ModifiedDate, ConstVariable.DateFormat1),
                    EntrustBatchNo = item.BatchNo.ToString(),
                    InstanceId     = item.InstanceId.ToString(),
                    InstanceNo     = item.InstanceCode,
                    DealNo         = item.EntrustNo.ToString(),
                };

                dfItems.Add(dfItem);
            }

            return(dfItems);
        }
 //Print the SamplePoint in the SampleSet object as an output.
 //@param sampleSet indicating the sampling dataset)
 private void DumpSampleSet(SampleSet sampleSet)
 {
     Logger("Returned for SamplePoint and Data type: " + sampleSet.DataType.Name);
     foreach (SamplePoint dp in sampleSet.SamplePoints)
     {
         DateFormat dateFormat = DateFormat.TimeInstance;
         Logger("SamplePoint:");
         Logger("DataCollector:" + dp.DataCollector.DataCollectorName);
         Logger("\tType: " + dp.DataType.Name);
         Logger("\tStart: " + dateFormat.Format(dp.GetStartTime(TimeUnit.Milliseconds)));
         Logger("\tEnd: " + dateFormat.Format(dp.GetEndTime(TimeUnit.Milliseconds)));
         foreach (Field field in dp.DataType.Fields)
         {
             Logger("\tField: " + field.ToString() + " Value: " + dp.GetFieldValue(field));
         }
     }
 }
        public static void LogMessage(Context context, string message)
        {
            ISharedPreferences prefs = GetPrefs(context);

            message = DATE_FORMAT.Format(new Date(JavaSystem.CurrentTimeMillis())) + ": " + message;
            prefs.Edit()
            .PutString(LOG_KEY, prefs.GetString(LOG_KEY, "") + LINE_BREAKS + message)
            .Apply();
        }
Example #11
0
        public void RefreshCalendar()
        {
            TextView title = (TextView)FindViewById(Resource.Id.title);

            calendarAdapter.RefreshDays();
            calendarAdapter.NotifyDataSetChanged();

            title.Text = DateFormat.Format("MMMM yyyy", month);
        }
Example #12
0
        public static string formatMillis(long time)
        {
            Calendar calendar = Calendar.Instance;

            calendar.Clear();
            calendar.Add(Calendar.Millisecond, (int)time);
            String pattern = time / Constants.hourMillis > 0 ? "kk:mm:ss" : "mm:ss";

            return(DateFormat.Format(pattern, calendar));
        }
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            var myHolder = (ViewHolder)holder;

            myHolder.PackageName.Text =
                mCustomUsageStatsList [position].UsageStats.PackageName;
            long lastTimeUsed = mCustomUsageStatsList [position].UsageStats.LastTimeUsed;

            myHolder.LastTimeUsed.Text = mDateFormat.Format(new Date(lastTimeUsed));
            myHolder.AppIcon.SetImageDrawable(mCustomUsageStatsList [position].AppIcon);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);
            time      = FindViewById <TextView>(Resource.Id.time);
            startStop = FindViewById <Button>(Resource.Id.start_stop);
            reset     = FindViewById <Button>(Resource.Id.reset);

            model = (StopwatchViewModel)ViewModelProviders.Of(this).Get(Java.Lang.Class.FromType(typeof(StopwatchViewModel)));
            model.running.Observe(this, new OnChangedHandler(() =>
            {
                startStop.Text = GetString(model.Running ? Resource.String.stop : Resource.String.start);
                reset.Enabled  = !model.Running;
            }));
            model.diff.Observe(this, new OnChangedHandler(() =>
            {
                time.Text = F.Format(new Date(model.Diff));
            }));
            StopwatchLifecycleObserver observer = new StopwatchLifecycleObserver(model);

            startStopClicked = (object sender, EventArgs e) =>
            {
                model.Running = !model.Running;
                if (model.Running)
                {
                    observer.ScheduleAtFixedRate();
                }
                else
                {
                    observer.Stop();
                }
            };
            startStop.Click += startStopClicked;

            resetClicked = (object sender, EventArgs e) => { model.Diff = 0; };
            reset.Click += resetClicked;

            Lifecycle.AddObserver(observer);
            UpdateButtons();
            UpdateTime();
        }
            public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
            {
                var           itemViewHolder = holder as ItemViewHolder;
                ItemData      data           = _activity.mDataSet[position];
                ShapeDrawable drawable       = new ShapeDrawable(new OvalShape());

                drawable.Paint.Color           = new Color(data.color);
                itemViewHolder.icon.Background = drawable;
                itemViewHolder.icon.SetImageResource(data.icon);
                itemViewHolder.title.Text    = data.title;
                itemViewHolder.subTitle.Text = dateFormat.Format(data.time);
            }
        // Print the ActivityRecord object as an output.
        private void DumpActivityRecord(ActivityRecord activityRecord)
        {
            DateFormat dateFormat = DateFormat.DateInstance;
            DateFormat timeFormat = DateFormat.TimeInstance;

            Logger("ActivityRecord Printing -------------------------------------");
            Logger("Returned for ActivityRecord: " + activityRecord.Name + "\n\tActivityRecord Identifier is "
                   + activityRecord.Id + "\n\tActivityRecord created by app is " + activityRecord.PackageName
                   + "\n\tDescription: " + activityRecord.Desc + "\n\tStart: "
                   + dateFormat.Format(activityRecord.GetStartTime(TimeUnit.Milliseconds)) + " "
                   + timeFormat.Format(activityRecord.GetStartTime(TimeUnit.Milliseconds)) + "\n\tEnd: "
                   + dateFormat.Format(activityRecord.GetEndTime(TimeUnit.Milliseconds)) + " "
                   + timeFormat.Format(activityRecord.GetEndTime(TimeUnit.Milliseconds)) + "\n\tActivity:"
                   + activityRecord.ActivityType);
            if (activityRecord.ActivitySummary != null)
            {
                PrintActivitySummary(activityRecord.ActivitySummary);
            }

            Logger("ActivityRecord Printing End ----------------------------------");
        }
        // Print the ActivitySummary object as an output.
        public void PrintActivitySummary(ActivitySummary activitySummary)
        {
            DateFormat          timeFormat  = DateFormat.TimeInstance;
            IList <SamplePoint> dataSummary = activitySummary.DataSummary;

            Logger("\nActivitySummary\n\t DataSummary: ");
            foreach (SamplePoint samplePoint in dataSummary)
            {
                Logger("\n\t samplePoint: \n\t DataCollector " + samplePoint.DataCollector.DataCollectorName + "\n\t DataType "
                       + samplePoint.DataType.Name + "\n\t StartTime " + timeFormat.Format(samplePoint.GetStartTime(TimeUnit.Milliseconds))
                       + "\n\t EndTime " + timeFormat.Format(samplePoint.GetEndTime(TimeUnit.Milliseconds)) + "\n\t SamplingTime "
                       + timeFormat.Format(samplePoint.GetSamplingTime(TimeUnit.Milliseconds)) + "\n\t FieldValues"
                       + ShowDictionaryValues(samplePoint.FieldValues));
            }
            // Printing PaceSummary
            PaceSummary paceSummary = activitySummary.PaceSummary;

            Logger("\n\t PaceSummary: \n\t AvgPace" + paceSummary.AvgPace + "\n\t BestPace" + paceSummary.BestPace
                   + "\n\t PaceMap" + ShowDictionaryValues(paceSummary.PaceMap) + "\n\t PartTimeMap" + ShowDictionaryValues(paceSummary.PartTimeMap) + "\n\t BritishPaceMap" + ShowDictionaryValues(paceSummary.BritishPaceMap) + "\n\t BritishPartTimeMap"
                   + ShowDictionaryValues(paceSummary.BritishPartTimeMap) + "\n\t SportHealthPaceMap" + ShowDictionaryValues(paceSummary.SportHealthPaceMap));
        }
 private void FillEdit(CommandManagementItem cmdMngItem)
 {
     this.tbBasisPoint.Text = "0";
     this.tbTemplate.Text   = string.Format("{0}--{1}", cmdMngItem.TemplateId, cmdMngItem.TemplateName);
     //TODO: submit person
     this.tbFutures.Text       = cmdMngItem.BearContract;
     this.tbStartDate.Text     = DateFormat.Format(cmdMngItem.DStartDate, ConstVariable.DateFormat1);
     this.tbEndDate.Text       = DateFormat.Format(cmdMngItem.DEndDate, ConstVariable.DateFormat1);
     this.tbStartTime.Text     = DateFormat.Format(cmdMngItem.DStartDate, ConstVariable.TimeFormat1);
     this.tbEndTime.Text       = DateFormat.Format(cmdMngItem.DEndDate, ConstVariable.TimeFormat1);
     this.tbAdjProportion.Text = "100";
     //TODO: operation level
     this.tbNotes.Text = cmdMngItem.Notes;
 }
Example #19
0
        public void TestYear()
        {
            // Gregorian Calendar
            IBM.ICU.Util.Calendar gCal = new IBM.ICU.Util.GregorianCalendar();
            DateTime gToday            = gCal.GetTime();

            gCal.Add(IBM.ICU.Util.Calendar.MONTH, 2);
            DateTime   gFuture = gCal.GetTime();
            DateFormat gDF     = IBM.ICU.Text.DateFormat.GetDateInstance(gCal, IBM.ICU.Text.DateFormat.FULL);

            Logln("gregorian calendar: " + gDF.Format(gToday) + " + 2 months = "
                  + gDF.Format(gFuture));

            // Indian Calendar
            IndianCalendar iCal   = new IndianCalendar();
            DateTime       iToday = iCal.GetTime();

            iCal.Add(IBM.ICU.Util.Calendar.MONTH, 2);
            DateTime   iFuture = iCal.GetTime();
            DateFormat iDF     = IBM.ICU.Text.DateFormat.GetDateInstance(iCal, IBM.ICU.Text.DateFormat.FULL);

            Logln("Indian calendar: " + iDF.Format(iToday) + " + 2 months = "
                  + iDF.Format(iFuture));
        }
Example #20
0
        /// <summary>
        /// Formats time in ms and appends difference (finishTime - startTime)
        /// as returned by formatTimeDiff().
        /// </summary>
        /// <remarks>
        /// Formats time in ms and appends difference (finishTime - startTime)
        /// as returned by formatTimeDiff().
        /// If finish time is 0, empty string is returned, if start time is 0
        /// then difference is not appended to return value.
        /// </remarks>
        /// <param name="dateFormat">date format to use</param>
        /// <param name="finishTime">fnish time</param>
        /// <param name="startTime">start time</param>
        /// <returns>formatted value.</returns>
        public static string GetFormattedTimeWithDiff(DateFormat dateFormat, long finishTime
                                                      , long startTime)
        {
            StringBuilder buf = new StringBuilder();

            if (0 != finishTime)
            {
                buf.Append(dateFormat.Format(Extensions.CreateDate(finishTime)));
                if (0 != startTime)
                {
                    buf.Append(" (" + FormatTimeDiff(finishTime, startTime) + ")");
                }
            }
            return(buf.ToString());
        }
        private static IList <object> GetList()
        {
            int    n    = 60; // number of series elements
            string time = "";

            System.Random random = new System.Random();
            int           temp;

            for (int i = 0; i < n; i++)
            {
                temp = random.Next(100);
                time = DateFormat.Format("mm:ss", new Date()).ToString();
                mList.Add(new ChartPoint(time, temp, temp + 10, temp + 20));
            }
            return(mList);
        }
        public static string Convert(int hours, int minutes)
        {
            // For this date, we only care about hour and minute
            // We set the date on the first of January 2000 as a dummy value
            // This is faster than doing GetYear(), GetMonth(), etc...
            Date date = new Date(2000, 1, 1, hours, minutes, 0);

            if (!DateFormat.Is24HourFormat(Application.Context))
            {
                return(DateFormat.Format("h:mm a", date));
            }
            else
            {
                return(DateFormat.Format("HH:mm", date));
            }
        }
        public void OnPositiveButtonClicked(int resultCode, Date date)
        {
            string text = "";

            if (resultCode == REQUEST_DATE_PICKER)
            {
                text = "Date ";
            }
            else if (resultCode == REQUEST_TIME_PICKER)
            {
                text = "Time ";
            }

            DateFormat dateFormat = DateFormat.DateTimeInstance;

            Toast.MakeText(this, text + "Success! " + dateFormat.Format(date), ToastLength.Short).Show();
        }
        // IDateDialogListener
        public void OnNegativeButtonClicked(int resultCode, Date date)
        {
            string text = "";

            if (resultCode == REQUEST_DATE_PICKER)
            {
                text = "Date ";
            }
            else if (resultCode == REQUEST_TIME_PICKER)
            {
                text = "Time ";
            }

            DateFormat dateFormat = DateFormat.GetDateInstance(DateFormat.Default);

            Toast.MakeText(this, text + "Cancelled " + dateFormat.Format(date), ToastLength.Short).Show();
        }
        private void FillSummary(CommandManagementItem cmdMngItem)
        {
            if (cmdMngItem == null)
            {
                return;
            }

            this.tbCommandId.Text     = string.Format("{0}", cmdMngItem.CommandId);
            this.tbFundName.Text      = string.Format("{0}--{1}", cmdMngItem.FundCode, cmdMngItem.FundName);
            this.tbPortfolioName.Text = string.Format("{0}--{1}", cmdMngItem.PortfolioCode, cmdMngItem.PortfolioName);
            this.tbCommandType.Text   = string.Empty;
            this.tbArbType.Text       = string.Empty;
            this.tbExecuteStage.Text  = string.Empty;
            this.tbInstNo.Text        = string.Format("{0}", cmdMngItem.InstanceId);
            this.tbInstCode.Text      = string.Format("{0}", cmdMngItem.InstanceCode);
            this.tbSubmitDate.Text    = DateFormat.Format(cmdMngItem.DDate, ConstVariable.DateFormat);
            this.tbSubmitTime.Text    = DateFormat.Format(cmdMngItem.DDate, ConstVariable.TimeFormat);
        }
        protected override string Convert(long value, Type targetType, object parameter, CultureInfo culture)
        {
            DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeSeconds(value);
            DateTime       localDate      = dateTimeOffset.LocalDateTime;

            // For this date, we only care about hour and minute
            // We set the date on the first of January 2000 as a dummy value
            // This is faster than doing GetYear(), GetMonth(), etc...
            Date date = new Date(2000, 1, 1, localDate.Hour, localDate.Minute, 0);

            if (!DateFormat.Is24HourFormat(Application.Context))
            {
                return(DateFormat.Format("h:mm a", date));
            }
            else
            {
                return(DateFormat.Format("HH:mm", date));
            }
        }
Example #27
0
        public override void HandleMessage(Message msg)
        {
            base.HandleMessage(msg);
            switch (msg.What)
            {
            case 0:            //update system time
                tv_system_time.Text = DateFormat.Format("kk:mm:ss", Java.Lang.JavaSystem.CurrentTimeMillis());
                SendEmptyMessageDelayed(Constants.UPDATE_SYSTEM_TIME, 1000);
                break;

            case 1:            //update current position
                tv_position.Text = Utils.formatMillis(vv.CurrentPosition);
                sb.Progress      = (int)vv.CurrentPosition;
                SendEmptyMessageDelayed(Constants.UPDATE_CURRENT_POSITION, 300);
                break;

            default:
                break;
            }
        }
Example #28
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            var myHolder = (ViewHolder)holder;

            myHolder.PackageName.Text =
                mCustomUsageStatsList[position].AppName;
            long lastTimeUsed = mCustomUsageStatsList[position].UsageStats.LastTimeUsed;

            myHolder.LastTimeUsed.Text = mDateFormat.Format(new Date(lastTimeUsed));
            TimeSpan timeSpan = TimeSpan.FromMilliseconds(mCustomUsageStatsList[position].UsageStats.TotalTimeInForeground);

            if (timeSpan.Days > 0)
            {
                myHolder.TotalTimeSpent.Text = string.Format("{0} days {1:D2} hours : {2:D2} min : {3:D2} sec",
                                                             timeSpan.Days,
                                                             timeSpan.Hours,
                                                             timeSpan.Minutes,
                                                             timeSpan.Seconds);
            }
            else if (timeSpan.Hours > 0)
            {
                myHolder.TotalTimeSpent.Text = string.Format("{0:D2} hours : {1:D2} min : {2:D2} sec",
                                                             timeSpan.Hours,
                                                             timeSpan.Minutes,
                                                             timeSpan.Seconds);
            }
            else if (timeSpan.Minutes > 0)
            {
                myHolder.TotalTimeSpent.Text = string.Format("{0:D2} min : {1:D2} sec",
                                                             timeSpan.Minutes,
                                                             timeSpan.Seconds);
            }
            else
            {
                myHolder.TotalTimeSpent.Text = string.Format("{0:D2} sec",
                                                             timeSpan.Seconds);
            }

            myHolder.AppIcon.SetImageDrawable(mCustomUsageStatsList[position].AppIcon);
        }
Example #29
0
        public void TestFormat()
        {
            ChineseCalendar cal = new ChineseCalendar();
            DateFormat      fmt = IBM.ICU.Text.DateFormat.GetDateTimeInstance(cal,
                                                                              IBM.ICU.Text.DateFormat.DEFAULT, IBM.ICU.Text.DateFormat.DEFAULT);

            IBM.ICU.Util.Calendar tempcal = IBM.ICU.Util.Calendar.GetInstance();
            tempcal.Clear();

            DateTime[] DATA = new DateTime[2];
            tempcal.Set(2001, IBM.ICU.Util.Calendar.MAY, 22);
            DATA[0] = tempcal.GetTime();
            tempcal.Set(2001, IBM.ICU.Util.Calendar.MAY, 23);
            DATA[1] = tempcal.GetTime();
            // Wed May 23 2001 = Month 4(leap), Day 1, Year 18, Cycle 78

            for (int i = 0; i < DATA.Length; ++i)
            {
                String s = fmt.Format(DATA[i]);
                try
                {
                    DateTime e = fmt.Parse(s);
                    if (e.Equals(DATA[i]))
                    {
                        Logln("Ok: " + DATA[i] + " -> " + s + " -> " + e);
                    }
                    else
                    {
                        Errln("FAIL: " + DATA[i] + " -> " + s + " -> " + e);
                    }
                }
                catch (ILOG.J2CsMapping.Util.ParseException e_0)
                {
                    Errln("Fail: " + s + " -> parse failure at "
                          + e_0.GetErrorOffset());
                    Errln(e_0.ToString());
                }
            }
        }
Example #30
0
        public void Test_getAvailableLocales()
        {
            Locale[] locales = DateFormat.GetAvailableLocales();
            NUnit.Framework.Assert.IsTrue(locales.Length > 0, "No locales");
            bool english = false, german = false;

            for (int i = locales.Length; --i >= 0;)
            {
                if (locales[i].Equals(Locale.US))
                {
                    english = true;
                }
                if (locales[i].Equals(Locale.GERMAN))
                {
                    german = true;
                }
                DateFormat f1 = DateFormat.GetDateTimeInstance(DateFormat.SHORT,
                                                               DateFormat.SHORT, locales[i]);
                NUnit.Framework.Assert.IsTrue((Object)f1.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work");
            }
            NUnit.Framework.Assert.IsTrue(english && german, "Missing locales");
        }