Beispiel #1
0
        /// <summary>
        /// Returns a string representation of the cell
        /// </summary>
        /// <returns>Formula cells return the formula string, rather than the formula result.
        /// Dates are displayed in dd-MMM-yyyy format
        /// Errors are displayed as #ERR&lt;errIdx&gt;
        /// </returns>
        public override String ToString()
        {
            switch (CellType)
            {
            case CellType.Blank:
                return("");

            case CellType.Boolean:
                return(BooleanCellValue ? "TRUE" : "FALSE");

            case CellType.Error:
                return(ErrorEval.GetText(ErrorCellValue));

            case CellType.Formula:
                return(CellFormula);

            case CellType.Numeric:
                if (DateUtil.IsCellDateFormatted(this))
                {
                    FormatBase sdf = new SimpleDateFormat("dd-MMM-yyyy");
                    return(sdf.Format(DateCellValue, CultureInfo.CurrentCulture));
                }
                return(NumericCellValue.ToString());

            case CellType.String:
                return(RichStringCellValue.ToString());

            default:
                return("Unknown Cell Type: " + CellType);
            }
        }
        /// <summary>Creates the Hadoop authentication HTTP cookie.</summary>
        /// <param name="token">authentication token for the cookie.</param>
        /// <param name="expires">
        /// UNIX timestamp that indicates the expire date of the
        /// cookie. It has no effect if its value &lt; 0.
        /// XXX the following code duplicate some logic in Jetty / Servlet API,
        /// because of the fact that Hadoop is stuck at servlet 2.5 and jetty 6
        /// right now.
        /// </param>
        public static void CreateAuthCookie(HttpServletResponse resp, string token, string
                                            domain, string path, long expires, bool isSecure)
        {
            StringBuilder sb = new StringBuilder(AuthenticatedURL.AuthCookie).Append("=");

            if (token != null && token.Length > 0)
            {
                sb.Append("\"").Append(token).Append("\"");
            }
            if (path != null)
            {
                sb.Append("; Path=").Append(path);
            }
            if (domain != null)
            {
                sb.Append("; Domain=").Append(domain);
            }
            if (expires >= 0)
            {
                DateTime         date = Extensions.CreateDate(expires);
                SimpleDateFormat df   = new SimpleDateFormat("EEE, " + "dd-MMM-yyyy HH:mm:ss zzz");
                df.SetTimeZone(Extensions.GetTimeZone("GMT"));
                sb.Append("; Expires=").Append(df.Format(date));
            }
            if (isSecure)
            {
                sb.Append("; Secure");
            }
            sb.Append("; HttpOnly");
            resp.AddHeader("Set-Cookie", sb.ToString());
        }
Beispiel #3
0
        void SetHeaderMonthDay(DatePickerDialog dialog, Locale locale)
        {
            if (headerTextView == null)
            {
                // Material Design formatted CalendarView being used, need to do API level check and skip on older APIs
                var id = base.Resources.GetIdentifier("date_picker_header_date", "id", "android");
                headerTextView          = dialog.DatePicker.FindViewById <TextView>(id);
                headerDatePatternLocale = Android.Text.Format.DateFormat.GetBestDateTimePattern(locale, "EMMMd");
                monthDayFormatLocale    = new SimpleDateFormat(headerDatePatternLocale, locale);
                headerTextView.SetTextColor(Android.Graphics.Color.Red);
                headerTextView.TextChanged += (sender, e) =>
                {
                    headerChangeFlag = !headerChangeFlag;
                    if (!headerChangeFlag)
                    {
                        return;
                    }
                    SetHeaderMonthDay(dialog, locale);
                };
            }
            var selectedDateLocale = monthDayFormatLocale.Format(new Date((long)dialog.DatePicker.DateTime.ToUniversalTime().Subtract(
                                                                              new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds));

            headerTextView.Text = selectedDateLocale;
        }
Beispiel #4
0
        private string GetFormattedDroppedTime(Calendar dropTime)
        {
            var format = new SimpleDateFormat("EEEE, d MMMM, h:mm a");
            var date   = format.Format(dropTime.Time);

            return(date.ToString());
        }
Beispiel #5
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     if (resultCode == Result.Ok)
     {
         HMEvent e = new HMEvent
         {
             name      = data.GetStringExtra("name"),
             date      = (Java.Util.Calendar)data.GetSerializableExtra("date"),
             location  = data.GetStringExtra("location"),
             duraion   = data.GetStringExtra("duration"),
             desc      = data.GetStringExtra("desc"),
             occurence = data.GetStringExtra("occ")
         };
         String           occ     = data.GetStringExtra("occ");
         SimpleDateFormat sdf     = new SimpleDateFormat("MM-dd-yyyy", new Locale("en_AU"));
         String           dateStr = sdf.Format(e.date.Time);
         if (requestCode == CalendarAdapter.ADD)
         {
             if (mDict.ContainsKey(dateStr))
             {
                 mDict[dateStr].Add(e);
             }
             else
             {
                 List <HMEvent> hMEvents = new List <HMEvent>();
                 hMEvents.Add(e);
                 mDict.Add(dateStr, hMEvents);
             }
         }
         else if (requestCode == CalendarAdapter.EDIT)
         {
             int    index      = data.GetIntExtra("index", -1);
             string originDate = data.GetStringExtra("originDate");
             if (index >= 0)
             {
                 if (mDict.ContainsKey(originDate))
                 {
                     mDict[originDate].RemoveAt(index);
                 }
                 if (mDict.ContainsKey(dateStr))
                 {
                     mDict[dateStr].Add(e);
                 }
                 else
                 {
                     List <HMEvent> hMEvents = new List <HMEvent>();
                     hMEvents.Add(e);
                     mDict.Add(dateStr, hMEvents);
                 }
                 if (mAdapterDict.ContainsKey(originDate))
                 {
                     mAdapterDict[originDate].NotifyDataSetChanged();
                 }
             }
         }
         initCalendar();
     }
 }
        public void OnTimeSet(TimePicker view, int hourOfDay, int minute)
        {
            SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm:aa");
            Time             time       = new Time(hourOfDay, minute, 0);
            String           strDate    = timeFormat.Format(time);

            etTime.Text = strDate;
        }
Beispiel #7
0
        /// <summary>
        /// 获取时间 小时:分;秒
        /// </summary>
        /// <returns>返回短时间字符串格式 HH:mm:ss</returns>
        public static String getTimeShort()
        {
            SimpleDateFormat formatter   = new SimpleDateFormat(Constant.TIME_STYLE1);
            Date             currentTime = new Date();
            String           dateString  = formatter.Format(currentTime);

            return(dateString);
        }
Beispiel #8
0
        /// <summary>Formats the given date according to the specified pattern.</summary>
        /// <remarks>
        /// Formats the given date according to the specified pattern.  The pattern
        /// must conform to that used by the
        /// <see cref="Sharpen.SimpleDateFormat">
        /// simple date
        /// format
        /// </see>
        /// class.
        /// </remarks>
        /// <param name="date">The date to format.</param>
        /// <param name="pattern">The pattern to use for formatting the date.</param>
        /// <returns>A formatted date string.</returns>
        /// <exception cref="System.ArgumentException">If the given date pattern is invalid.</exception>
        /// <seealso cref="Sharpen.SimpleDateFormat">Sharpen.SimpleDateFormat</seealso>
        public static string FormatDate(DateTime date, string pattern)
        {
            Args.NotNull(date, "Date");
            Args.NotNull(pattern, "Pattern");
            SimpleDateFormat formatter = DateUtils.DateFormatHolder.FormatFor(pattern);

            return(formatter.Format(date));
        }
Beispiel #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            SimpleDateFormat sdf = new SimpleDateFormat();

            sdf.ApplyPattern("yyyy-MM-dd HH:mm:ss a");
            Date date = new Date();

            Crashes.GetErrorAttachments = (ErrorReport report) =>
            {
                return(new ErrorAttachmentLog[]
                {
                    ErrorAttachmentLog.AttachmentWithText("Crash happened: Hello world! \r\n at " + sdf.Format(date), "hello.txt"),
                    //ErrorAttachmentLog.AttachmentWithBinary(data,"a.png","image/png")
                });
            };
            AppCenter.Start("474cb7fe-4c47-4dc2-b4f8-854f0eebe0d9", typeof(Analytics), typeof(Crashes));
            AppCenter.LogLevel = LogLevel.Verbose;


            Analytics.TrackEvent("Loading Main activity... , at " + sdf.Format(date));

            Button translateButton = FindViewById <Button>(Resource.Id.TranslateButton);

            translateButton.Click += (sender, e) =>
            {
                // Translate user's alphanumeric phone number to numeric
                //string translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);
                //if (string.IsNullOrWhiteSpace(translatedNumber))
                //{
                //    translatedPhoneWord.Text = string.Empty;
                //}
                //else
                //{
                //    translatedPhoneWord.Text = translatedNumber;
                //}
                var result = FromRainbow(Rainbow.Indigo);
                //Person p = new Person("Abraham", "Qian");
                Analytics.TrackEvent($"Now is: {sdf.Format(date)}. Result is: {result.C}");
                //Crashes.GenerateTestCrash();
                translateButton.Text = $"{result.C}";
            };
        }
		public void  OnDateChanged (DatePicker view, int year, int monthOfYear, int dayOfMonth)
		{
			var calendar = Calendar.Instance;
			calendar.Set (datePicker.Year, datePicker.Month, datePicker.DayOfMonth);
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			dateTime = sdf.Format (calendar.Time);

		}
        public static string Get24HourTimeFromTimeStamp(long timestamp)
        {
            SimpleDateFormat weatherDateTime = new SimpleDateFormat("HH:mm");
            Date             time            = new Date(timestamp * 1000);
            string           dateTime        = weatherDateTime.Format(time);

            return(dateTime);
        }
		public void OnTimeChanged (TimePicker view, int hourOfDay, int minute)
		{
			var calendar = Calendar.Instance;
			calendar.Set(CalendarField.HourOfDay,timePicker.CurrentHour.IntValue());
			calendar.Set (CalendarField.Minute, timePicker.CurrentMinute.IntValue());
			SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
			dateTime = sdf.Format (calendar.Time);
		}
        public static string GetDayOfTheWeek(long timestamp)
        {
            SimpleDateFormat weatherDateTime = new SimpleDateFormat("EEEE");
            Date             time            = new Date(timestamp * 1000);
            string           dateTime        = weatherDateTime.Format(time);

            return(dateTime);
        }
        public static string unixTimestampToDate(long timestamp)
        {
            SimpleDateFormat weatherDateTime = new SimpleDateFormat("EEEE, MMMM d");
            Date             time            = new Date(timestamp * 1000);
            string           dateTime        = weatherDateTime.Format(time);

            return(dateTime);
        }
Beispiel #15
0
        private string Iso(PersonIdent id)
        {
            SimpleDateFormat fmt;

            fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
            fmt.SetTimeZone(id.GetTimeZone());
            return(fmt.Format(id.GetWhen()));
        }
        public void Test_getDateInstanceI()
        {
            NUnit.Framework.Assert.IsTrue(DateFormat.DEFAULT == DateFormat.MEDIUM, "Default not medium");

            SimpleDateFormat f2 = (SimpleDateFormat)DateFormat
                                  .GetDateInstance(DateFormat.SHORT);

            NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class1");
            NUnit.Framework.Assert.IsTrue(f2.Equals(DateFormat.GetDateInstance(DateFormat.SHORT,
                                                                               Locale.GetDefault())), "Wrong default1");
            NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols1");
            NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work1");

            f2 = (SimpleDateFormat)DateFormat.GetDateInstance(DateFormat.MEDIUM);
            NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class2");
            NUnit.Framework.Assert.IsTrue(f2.Equals(DateFormat.GetDateInstance(DateFormat.MEDIUM,
                                                                               Locale.GetDefault())), "Wrong default2");
            NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols2");
            NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work2");

            f2 = (SimpleDateFormat)DateFormat.GetDateInstance(DateFormat.LONG);
            NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class3");
            NUnit.Framework.Assert.IsTrue(f2.Equals(DateFormat.GetDateInstance(DateFormat.LONG,
                                                                               Locale.GetDefault())), "Wrong default3");
            NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols3");
            NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work3");

            f2 = (SimpleDateFormat)DateFormat.GetDateInstance(DateFormat.FULL);
            NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class4");
            NUnit.Framework.Assert.IsTrue(f2.Equals(DateFormat.GetDateInstance(DateFormat.FULL,
                                                                               Locale.GetDefault())), "Wrong default4");
            NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols4");
            NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work4");

            // regression test for HARMONY-940
            try
            {
                DateFormat.GetDateInstance(77);
                NUnit.Framework.Assert.Fail("Should throw IAE");
            }
            catch (ArgumentException iae)
            {
                // expected
            }
        }
Beispiel #17
0
        public void OnTimeSet(TimePicker view, int hourOfDay, int minute)
        {
            SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm:ss");
            Date             timeNew    = new Date(0, 0, 0, hourOfDay, minute);
            String           strDate    = timeFormat.Format(timeNew);

            timeCita.Text = $"{strDate}";
            time          = $"{strDate}";
        }
        private string GetFormatedDate(string date)
        {
            //string format = "MM/dd/yyyy HH:mm:ss";
            string           format = "dd MMM hh:mm a";
            SimpleDateFormat sdf    = new SimpleDateFormat(format);
            string           dt     = sdf.Format(new Java.Util.Date(date));

            return(dt);
        }
Beispiel #19
0
        public static void WriteLog(System.Exception ex)
        {
            SimpleDateFormat format   = new SimpleDateFormat("yyyy-MM-dd");
            string           fileName = format.Format(new Date()) + ".log";
            File             file     = new File(CreateRootPath(MainApplication.Context) + "/log/dcms_" + fileName);

            CreateFile(file);
            WriteFile(file.AbsolutePath, ex.ToFormattedString());
        }
Beispiel #20
0
            public string InterpretDate(Calendar date)
            {
                int year  = date.Get(CalendarField.Year);
                int month = date.Get(CalendarField.Month);
                int day   = date.Get(CalendarField.DayOfMonth);
                SimpleDateFormat weekdayNameFormat = new SimpleDateFormat("EEE", Locale.Default);
                String           weekday           = weekdayNameFormat.Format(date.Time);
                SimpleDateFormat format            = new SimpleDateFormat(" M/d", Locale.Default);

                String test = "";

                switch (weekday.ToLower())
                {
                case "sat":
                    test = "شنبه";
                    break;

                case "sun":
                    test = "یکشنبه";
                    break;

                case "mon":
                    test = "دوشنبه";
                    break;

                case "tue":
                    test = "سه شنبه";
                    break;

                case "wed":
                    test = "چهارشنبه";
                    break;

                case "thu":
                    test = "پنجشنبه";
                    break;

                case "fri":
                    test = "جمعه";
                    break;
                }

                PersianCalendar persianCalendar = new PersianCalendar(year, month, day);

                // All android api level do not have a standard way of getting the first letter of
                // the week day name. Hence we get the first char programmatically.
                // Details: http://stackoverflow.com/questions/16959502/get-one-letter-abbreviation-of-week-day-of-a-date-in-java#answer-16959657
                if (mShortDate)
                {
                    weekday = Convert.ToString(weekday[0]);
                    return(persianCalendar.getIranianDate());
                }
                else
                {
                    return(test.ToUpper() + " " + persianCalendar.getIranianDate());
                }
            }
Beispiel #21
0
        private void BtnLightImport_Click(object sender, EventArgs e)
        {
            textViewTips.Text = "灯光开始一键导入,请等待";
            File             file = new File(DictoryPath, "Light.config");
            SimpleDateFormat sdf  = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            string           date = sdf.Format(new Java.Util.Date(file.LastModified()));

            ShowQuestionDialog("导入灯光", string.Format("您确定需要导入{0}导出的灯光", date), LightCoverExport, LightNotCoverExport, "确定", "取消");
        }
Beispiel #22
0
        /// <summary>Print the provided date object using the default date format {@link #DEFAULT_XMLLIKE_DATE_FORMAT} </summary>
        /// <param name="date">should be long, Date or Calendar</param>
        /// <returns>date string</returns>
        public static String Print(Object date)
        {
            SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_XMLLIKE_DATE_FORMAT);

            if (date is Long)
            {
                return(sdf.Format(new Date((long?)date)));
            }
            if (date is Date)
            {
                return(sdf.Format((Date)date));
            }
            if (date is Calendar)
            {
                return(sdf.Format(((Calendar)date).Time));
            }
            throw new ArgumentException("Date format for type '" + date.Class + "' not possible");
        }
        public void  OnDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth)
        {
            var calendar = Calendar.Instance;

            calendar.Set(datePicker.Year, datePicker.Month, datePicker.DayOfMonth);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

            dateTime = sdf.Format(calendar.Time);
        }
        public void Test_getDateInstance()
        {
            SimpleDateFormat f2 = (SimpleDateFormat)DateFormat.GetDateInstance();

            NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class");
            NUnit.Framework.Assert.IsTrue(f2.Equals(DateFormat.GetDateInstance(DateFormat.DEFAULT,
                                                                               Locale.GetDefault())), "Wrong default");
            NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols");
            NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work");
        }
Beispiel #25
0
        public void OnTimeChanged(TimePicker view, int hourOfDay, int minute)
        {
            var calendar = Calendar.Instance;

            calendar.Set(CalendarField.HourOfDay, timePicker.CurrentHour.IntValue());
            calendar.Set(CalendarField.Minute, timePicker.CurrentMinute.IntValue());
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");

            dateTime = sdf.Format(calendar.Time);
        }
Beispiel #26
0
        private static string HttpNow()
        {
            string           tz = "GMT";
            SimpleDateFormat fmt;

            fmt = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", CultureInfo.InvariantCulture
                                       );
            fmt.SetTimeZone(Sharpen.Extensions.GetTimeZone(tz));
            return(fmt.Format(new DateTime()) + " " + tz);
        }
Beispiel #27
0
        public static void WriteLocation(this ExifInterface exif, Location location)
        {
            exif.SetAttribute(ExifInterface.TagGpsLatitude, GPS.Convert(location.Latitude));
            exif.SetAttribute(ExifInterface.TagGpsLatitudeRef, GPS.LatitudeRef(location.Latitude));
            exif.SetAttribute(ExifInterface.TagGpsLongitude, GPS.Convert(location.Longitude));
            exif.SetAttribute(ExifInterface.TagGpsLongitudeRef, GPS.LongitudeRef(location.Longitude));

            exif.SetAttribute(ExifInterface.TagDatetime, ExifFormat.Format(new Date(location.Time)));
            exif.SaveAttributes();
        }
Beispiel #28
0
        private void BtnImport_Click(object sender, EventArgs e)
        {
            //读取文件
            textViewTips.Text = "开始一键导入,请等待";
            File             file = new File(DictoryPath, "config.config");
            SimpleDateFormat sdf  = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            string           date = sdf.Format(new Java.Util.Date(file.LastModified()));

            ShowQuestionDialog("导入配置", string.Format("您确定需要恢复{0}导出的配置", date), ImportSuccess, ImportCancel, "确定", "取消");
        }
        public static IDictionary <string, object> ToDictionary(this IDictionary <string, Java.Lang.Object> map)
        {
            var dict = new Dictionary <string, object>();

            foreach (var key in map.Keys)
            {
                var value = map[key];
                if (value is Java.Lang.Boolean bln)
                {
                    dict.Add(key, bln.BooleanValue());
                }
                else if (value is Java.Lang.Long lng)
                {
                    dict.Add(key, lng.IntValue());
                }
                else if (value is Java.Lang.Integer integer)
                {
                    dict.Add(key, integer.IntValue());
                }
                else if (value is Java.Lang.Double dbl)
                {
                    dict.Add(key, dbl.DoubleValue());
                }
                else if (value is Java.Lang.String str)
                {
                    dict.Add(key, str.ToString());
                }
                else if (value is Java.Util.Date dt)
                {
                    var dtFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
                    dict.Add(key, dtFormat.Format(dt));
                }
                else if (value.Class.IsInstance(new ArrayList()))
                {
                    if (value is System.Collections.ICollection collection)
                    {
                        var lst  = new List <string>();
                        var list = new ArrayList(collection);
                        for (var i = 0; i < list.Size(); i++)
                        {
                            var item    = list.Get(i);
                            var itemStr = item.ToString();
                            lst.Add(itemStr);
                        }
                        dict.Add(key, lst);
                    }
                }
                else
                {
                    dict.Add(key, value.ToString());
                }
            }

            return(dict);
        }
        public void Test_getTimeInstanceILjava_util_Locale()
        {
            SimpleDateFormat f2 = (SimpleDateFormat)DateFormat.GetTimeInstance(
                DateFormat.SHORT, Locale.GERMAN);

            NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class");
            NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(
                                              new DateFormatSymbols(Locale.GERMAN)), "Wrong symbols");
            NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work");

            f2 = (SimpleDateFormat)DateFormat.GetTimeInstance(DateFormat.MEDIUM,
                                                              Locale.GERMAN);
            NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class");
            NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(
                                              new DateFormatSymbols(Locale.GERMAN)), "Wrong symbols");
            NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work");

            f2 = (SimpleDateFormat)DateFormat.GetTimeInstance(DateFormat.LONG,
                                                              Locale.GERMAN);
            NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class");
            NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(
                                              new DateFormatSymbols(Locale.GERMAN)), "Wrong symbols");
            NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work");

            f2 = (SimpleDateFormat)DateFormat.GetTimeInstance(DateFormat.FULL,
                                                              Locale.GERMAN);
            NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class");
            NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(
                                              new DateFormatSymbols(Locale.GERMAN)), "Wrong symbols");
            NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work");

            // regression test for HARMONY-940
            try
            {
                DateFormat.GetTimeInstance(77, Locale.GERMAN);
                NUnit.Framework.Assert.Fail("Should throw IAE");
            }
            catch (ArgumentException iae)
            {
                // expected
            }
        }
Beispiel #31
0
        private void PrintBlockDeletionTime(Logger log)
        {
            log.Info(DFSConfigKeys.DfsNamenodeStartupDelayBlockDeletionSecKey + " is set to "
                     + DFSUtil.DurationToString(pendingPeriodInMs));
            SimpleDateFormat sdf      = new SimpleDateFormat("yyyy MMM dd HH:mm:ss");
            Calendar         calendar = new GregorianCalendar();

            calendar.Add(Calendar.Second, (int)(this.pendingPeriodInMs / 1000));
            log.Info("The block deletion will start around " + sdf.Format(calendar.GetTime())
                     );
        }
Beispiel #32
0
        /**
         * Returns Subscription end date
         * Date returned by this method is kept as the current date plus 3 years.
         */
        private String CreateSubscriptionEndDate()
        {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            Calendar         c  = Calendar.GetInstance(Locale.Default);

            c.Add(CalendarField.Year, 3);
            Date   future          = c.Time;
            String dateInISOFormat = df.Format(future);

            return(dateInISOFormat);
        }
 public static string GetMonthDate(Date date, Locale locale, Context context)
 {
     if (Build.VERSION.SdkInt >= Build.VERSION_CODES.JellyBeanMr2)
     {
         var pattern = Android.Text.Format.DateFormat.GetBestDateTimePattern(locale, FORMAT_MMDD);
         var sdf = new SimpleDateFormat(pattern, locale);
         return sdf.Format(date);
     }
     else
     {
         var flag = FormatStyleFlags.ShowDate | FormatStyleFlags.NoYear;
         return DateUtils.FormatDateTime(context, date.Time, flag);
     }
 }
        /// <summary>
        /// Called when [date set].
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="year">The year.</param>
        /// <param name="monthOfYear">The month of year.</param>
        /// <param name="dayOfMonth">The day of month.</param>
        public void OnDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
        {
            try
            {
                Date curDate = new Date(year - 1900, monthOfYear, dayOfMonth);
                string pattern = "MM/dd/yyyy";
                SimpleDateFormat format = new SimpleDateFormat(pattern);

                ApplicationData.CurrentDate = format.Format(curDate);
                if (SetDate != null)
                {
                    SetDate();
                }
            }
            catch (Exception)
            {
            }
        }
 public static string GetDateTimeNow(string format)
 {
     Calendar currentDefaultCalendar = Calendar.GetInstance(Locale.Default);
     SimpleDateFormat enviromentFormat = new SimpleDateFormat(format);
     return enviromentFormat.Format(currentDefaultCalendar);
 }
		public override View GetSampleContent (Context con)
		{
			SimpleDateFormat sdf = new SimpleDateFormat("HH mm ss");
			string currentDateandTime = sdf.Format(new Java.Util.Date());
			digitalGauge1 = new SfDigitalGauge(con);
			digitalGauge2 = new SfDigitalGauge(con);
			digitalGauge3 = new SfDigitalGauge(con);
			digitalGauge4 = new SfDigitalGauge(con);

			LinearLayout dln1 = new LinearLayout(con);
			dln1.SetGravity(GravityFlags.Center);
			dln1.AddView(digitalGauge1);
			digitalGauge1.CharacterStroke = Color.Rgb(20,108,237);
			digitalGauge1.CharacterHeight = 25 ;
			digitalGauge1.CharactersSpacing = 2;
			digitalGauge1.CharacterWidth = 12;
			digitalGauge1.SegmentStrokeWidth = 2;
			digitalGauge1.CharacterType = CharacterTypes.SegmentSeven;
			digitalGauge1.Value = currentDateandTime.ToString();
			digitalGauge1.DimmedSegmentColor = Color.Rgb(20,108,237);
			digitalGauge1.DimmedSegmentAlpha = 30;
			float cheight = TypedValue.ApplyDimension(ComplexUnitType.Pt,(float) digitalGauge1.CharacterHeight , con.Resources.DisplayMetrics);
			float cwidth = TypedValue.ApplyDimension(ComplexUnitType.Pt,(float)(8 * digitalGauge1.CharacterWidth + 8 * digitalGauge1.CharactersSpacing) , con.Resources.DisplayMetrics);
			digitalGauge1.LayoutParameters = (new LinearLayout.LayoutParams((int)cwidth, (int) cheight));
			digitalGauge1.SetBackgroundColor(Color.Rgb(240,240,240));
			digitalGauge2.SetBackgroundColor(Color.Rgb(240,240,240));
			digitalGauge3.SetBackgroundColor(Color.Rgb(240,240,240));
			digitalGauge4.SetBackgroundColor(Color.Rgb(240,240,240));

			LinearLayout dln2 = new LinearLayout(con);
			dln2.SetGravity(GravityFlags.Center);
			dln2.AddView(digitalGauge2);
			digitalGauge2.DimmedSegmentAlpha = 30;
			digitalGauge2.DimmedSegmentColor = Color.Rgb(2,186,94);
			digitalGauge2.CharacterStroke = Color.Rgb(2,186,94);
			digitalGauge2.CharacterHeight = 25 ;
			digitalGauge2.CharactersSpacing = 2;
			digitalGauge2.CharacterWidth = 12;
			digitalGauge2.SegmentStrokeWidth = 2;
			digitalGauge2.CharacterType = CharacterTypes.SegmentFourteen;
			digitalGauge2.Value = currentDateandTime;
			float cheight1 = TypedValue.ApplyDimension(ComplexUnitType.Pt,(float) digitalGauge2.CharacterHeight , con.Resources.DisplayMetrics);
			float cwidth1 = TypedValue.ApplyDimension(ComplexUnitType.Pt,(float)(8*digitalGauge2.CharacterWidth+8*digitalGauge2.CharactersSpacing) , con.Resources.DisplayMetrics);
			digitalGauge2.LayoutParameters = (new LinearLayout.LayoutParams((int)cwidth1, (int) cheight1));

			LinearLayout dln3 = new LinearLayout(con);
			dln3.SetGravity(GravityFlags.Center);
			dln3.AddView(digitalGauge3);
			digitalGauge3.DimmedSegmentAlpha = 30;
			digitalGauge3.DimmedSegmentColor = Color.Rgb(219,153,7);
			digitalGauge3.CharacterStroke = Color.Rgb(219,153,7);
			digitalGauge3.CharacterHeight = 25 ;
			digitalGauge3.CharactersSpacing = 2;
			digitalGauge3.CharacterWidth = 12;
			digitalGauge3.SegmentStrokeWidth = 2;
			digitalGauge3.CharacterType = CharacterTypes.SegmentSixteen;
			digitalGauge3.Value = currentDateandTime;
			float cheight2 = TypedValue.ApplyDimension(ComplexUnitType.Pt,(float) digitalGauge3.CharacterHeight , con.Resources.DisplayMetrics);
			float cwidth2 = TypedValue.ApplyDimension(ComplexUnitType.Pt,(float)(8*digitalGauge3.CharacterWidth+8*digitalGauge3.CharactersSpacing) , con.Resources.DisplayMetrics);
			digitalGauge3.LayoutParameters = (new LinearLayout.LayoutParams((int)cwidth2, (int) cheight2));

			LinearLayout dln4 = new LinearLayout(con);
			dln4.SetGravity(GravityFlags.Center);
			dln4.AddView(digitalGauge4);
			digitalGauge4.DimmedSegmentAlpha = 30;
			digitalGauge4.DimmedSegmentColor = Color.Rgb(249,66,53);
			digitalGauge4.CharacterStroke = Color.Rgb(249,66,53);
			digitalGauge4.CharacterHeight = 25 ;
			digitalGauge4.CharactersSpacing = 5;
			digitalGauge4.CharacterWidth = 9;
			digitalGauge4.SegmentStrokeWidth = 2;
			digitalGauge4.CharacterType = CharacterTypes.EightCrossEightDotMatrix;
			digitalGauge4.Value = currentDateandTime;
			float cheight3 = TypedValue.ApplyDimension(ComplexUnitType.Pt,(float) digitalGauge4.CharacterHeight , con.Resources.DisplayMetrics);
			float cwidth4 = TypedValue.ApplyDimension(ComplexUnitType.Pt,(float)(8*digitalGauge4.CharacterWidth+8*digitalGauge4.CharactersSpacing) , con.Resources.DisplayMetrics);
			digitalGauge4.LayoutParameters = (new LinearLayout.LayoutParams((int)cwidth4, (int) cheight3));

			text1 = new TextView(con);
			text2 = new TextView(con);
			text3 = new TextView(con);
			text4 = new TextView(con);
			text5 = new TextView(con);
			text6 = new TextView(con);
			text7 = new TextView(con);
			text8 = new TextView(con);

			LinearLayout tln1 = new LinearLayout(con);
			tln1.SetGravity(GravityFlags.Center);
			tln1.AddView(text1);
			LinearLayout tln2 = new LinearLayout(con);
			tln2.SetGravity(GravityFlags.Center);
			tln2.AddView(text2);
			LinearLayout tln3 = new LinearLayout(con);
			tln3.SetGravity(GravityFlags.Center);
			tln3.AddView(text3);
			LinearLayout tln4 = new LinearLayout(con);
			tln4.SetGravity(GravityFlags.Center);
			tln4.AddView(text4);
			text1.Text = "7 Segment";
			text1.SetTextColor(Color.Rgb(34,34,34));
			text1.TextSize = TypedValue.ApplyDimension(ComplexUnitType.Pt,8 , con.Resources.DisplayMetrics);

			text2.Text = "14 Segment";
			text2.SetTextColor(Color.Rgb(34,34,34));
			text2.TextSize = TypedValue.ApplyDimension(ComplexUnitType.Pt,8 , con.Resources.DisplayMetrics);

			text3.Text = "16 Segment";
			text3.SetTextColor(Color.Rgb(34,34,34));
			text3.TextSize = TypedValue.ApplyDimension(ComplexUnitType.Pt,8 , con.Resources.DisplayMetrics);

			text4.Text = "8 X 8 DotMatrix";
			text4.SetTextColor(Color.Rgb(34,34,34));
			text4.TextSize = TypedValue.ApplyDimension(ComplexUnitType.Pt,8 , con.Resources.DisplayMetrics);
			text5.TextSize = TypedValue.ApplyDimension(ComplexUnitType.Pt,8 , con.Resources.DisplayMetrics);
			text6.TextSize = TypedValue.ApplyDimension(ComplexUnitType.Pt,8 , con.Resources.DisplayMetrics);
			text7.TextSize = TypedValue.ApplyDimension(ComplexUnitType.Pt,8 , con.Resources.DisplayMetrics);
			text8.TextSize = TypedValue.ApplyDimension(ComplexUnitType.Pt,8 , con.Resources.DisplayMetrics);
			ScrollView sc = new ScrollView(con);
			sc.HorizontalScrollBarEnabled = true;
			LinearLayout fr = new LinearLayout(con);
			fr.Orientation = Orientation.Vertical;
			//fr.AddView(text5);
			fr.AddView(tln1);
			fr.AddView(dln1);
			fr.AddView(text6);
			fr.AddView(tln2);
			fr.AddView(dln2);
			fr.AddView(text7);
			fr.AddView(tln3);
			fr.AddView(dln3);
			fr.AddView(text8);
			fr.AddView(tln4);
			fr.AddView(dln4);
			fr.SetGravity(GravityFlags.Center);
			ScrollView scroll = new ScrollView (con);			
			LinearLayout ly = new LinearLayout(con);
			ly.AddView(fr);
			ly.SetBackgroundColor (Color.White);
			ly.SetGravity(GravityFlags.Center);
			//sc.addView(ly);
			sc.SetForegroundGravity(GravityFlags.Center);
			sc.SetPadding(2,2,2,2);
			sc.SetBackgroundColor(Color.Rgb(248,248,248));
			// Set our view from the "main" layout resource
			scroll.AddView(ly);
			return scroll;
		}
            /// <summary>
            /// Formats a number or date cell, be that a real number, or the
            /// answer to a formula
            /// </summary>
            /// <param name="cell">The cell.</param>
            /// <param name="value">The value.</param>
            /// <returns></returns>
            private String FormatNumberDateCell(CellValueRecordInterface cell, double value)
            {
                // Get the built in format, if there is one
                int formatIndex = ft.GetFormatIndex(cell);
                String formatString = ft.GetFormatString(cell);

                if (formatString == null)
                {
                    return value.ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    // Is it a date?
                    if (LF.Utils.NPOI.SS.UserModel.DateUtil.IsADateFormat(formatIndex, formatString) &&
                            LF.Utils.NPOI.SS.UserModel.DateUtil.IsValidExcelDate(value))
                    {
                        // Java wants M not m for month
                        formatString = formatString.Replace('m', 'M');
                        // Change \- into -, if it's there
                        formatString = formatString.Replace("\\\\-", "-");

                        // Format as a date
                        DateTime d = LF.Utils.NPOI.SS.UserModel.DateUtil.GetJavaDate(value, false);
                        SimpleDateFormat df = new SimpleDateFormat(formatString);
                        return df.Format(d);
                    }
                    else
                    {
                        if (formatString == "General")
                        {
                            // Some sort of wierd default
                            return value.ToString(CultureInfo.InvariantCulture);
                        }

                        // Format as a number
                        DecimalFormat df = new DecimalFormat(formatString);
                        return df.Format(value);
                    }
                }
            }
Beispiel #38
0
 private ValueEval TryParseDateTime(double s0, string s1)
 {
     try
     {
         FormatBase dateFormatter = new SimpleDateFormat(s1);
         //first month of java Gregorian Calendar month field is 0
         DateTime dt = new DateTime(1899, 12, 30, 0, 0, 0);
         dt = dt.AddDays((int)Math.Floor(s0));
         double dayFraction = s0 - Math.Floor(s0);
         dt = dt.AddMilliseconds((int)Math.Round(dayFraction * 24 * 60 * 60 * 1000));
         return new StringEval(dateFormatter.Format(dt));
     }
     catch (Exception)
     {
         return ErrorEval.VALUE_INVALID;
     }
 }
//		@SuppressLint("SimpleDateFormat")
		private void UpdateTimeTab()
		{
			if (_isClientSpecified24HourTime)
			{
				SimpleDateFormat formatter;

				if (_is24HourTime)
				{
					formatter = new SimpleDateFormat("HH:mm");
					_slidingTabLayout.SetTabText(1, formatter.Format(_calendar.Time));
				}
				else
				{
					formatter = new SimpleDateFormat("h:mm aa");
					_slidingTabLayout.SetTabText (1, formatter.Format (_calendar.Time));
				}
			}
			else  // display time using the device's default 12/24 hour format preference
			{
				_slidingTabLayout.SetTabText(1, Android.Text.Format.DateFormat.GetTimeFormat(_context).Format(_calendar.TimeInMillis));
			}
		}
Beispiel #40
0
 public static string ToString(DateTime value, string format)
 {
     var simpleDateFormat = new SimpleDateFormat(ToJavaFormat(format), Locale.US);
     var result = simpleDateFormat.Format(value.ToDate());
     if (format.EndsWith("zzz"))
     {
         var tempResult = result;
         result = tempResult.Substring(0, tempResult.Length - 2) + ":" + tempResult.Substring(tempResult.Length - 2);
     }
     return result;
 }
		public RemoteViews GetViewAt (int position)
		{

			IList<RichPushMessage> messages = RichPushManager.Shared ().RichPushUser.Inbox.Messages;

			if (position > messages.Count) {
				return null;
			}

			// Get the data for this position from the content provider
			RichPushMessage message = messages [position];

			// Return a proper item
			String formatStr = context.Resources.GetString (Resource.String.item_format_string);
			int itemId = Resource.Layout.widget_item;
			RemoteViews rv = new RemoteViews (context.PackageName, itemId);
			rv.SetTextViewText (Resource.Id.widget_item_text, Java.Lang.String.Format (formatStr, message.Title));

			int iconDrawable = message.IsRead ? Resource.Drawable.mark_read : Resource.Drawable.mark_unread;
			rv.SetImageViewResource (Resource.Id.widget_item_icon, iconDrawable);

			SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd HH:mm");
			rv.SetTextViewText (Resource.Id.date_sent, dateFormat.Format (message.SentDate));

			// Add the message id to the intent
			Intent fillInIntent = new Intent ();
			Bundle extras = new Bundle ();
			extras.PutString (RichPushApplication.MESSAGE_ID_RECEIVED_KEY, message.MessageId);
			fillInIntent.PutExtras (extras);
			rv.SetOnClickFillInIntent (Resource.Id.widget_item, fillInIntent);

			return rv;
		}