public static Java.IO.File GetOutputMediaFile(UploadFileType type) { string extr = Android.OS.Environment.ExternalStorageDirectory.ToString(); Java.IO.File mFolder = new Java.IO.File(extr + "/TMMFOLDER"); if (!mFolder.Exists()) { mFolder.Mkdir(); } String timeStamp = new Java.Text.SimpleDateFormat("yyyyMMdd_HHmmss", Locale.Default).Format(new Date()); Java.IO.File mediaFile; if (type == UploadFileType.image) { mediaFile = new Java.IO.File(mFolder.AbsolutePath + Java.IO.File.Separator + "IMG_" + timeStamp + ".jpg"); } else { mediaFile = new Java.IO.File(mFolder.AbsolutePath + Java.IO.File.Separator + "VID_" + timeStamp + ".mp4"); } return(mediaFile); }
public void OnDayClick(Date p0) { try { Java.Text.SimpleDateFormat dateFormat = new Java.Text.SimpleDateFormat("YYYY-MM-dd hh:mm:ss"); DateTime sa = Convert.ToDateTime(dateFormat.Format(p0)); IList <Com.Github.Sundeepk.Compactcalendarview.Domain.Event> day_events = cview.GetEvents(p0); if (day_events != null && day_events.Count > default(int)) { //Redirect to ActivityDayView superObj.RedirectToDayView(sa); } else { throw new Exception(string.Format("No event found on {0}", sa.ToString("dd-MM-yyyy"))); } } catch (Exception ex) { currentActivity.RunOnUiThread(() => { Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity); alertDiag.SetTitle(Resource.String.DialogHeaderError); alertDiag.SetMessage(ex.Message); alertDiag.SetIcon(Resource.Drawable.alert); alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) => { }); Dialog diag = alertDiag.Create(); diag.Show(); diag.SetCanceledOnTouchOutside(false); }); } }
public int GetYear(long milTime) { Java.Text.SimpleDateFormat formatter = new Java.Text.SimpleDateFormat("YYYY"); string result = (string)formatter.Format(new Java.Sql.Timestamp(milTime)); return(Convert.ToInt32(result)); }
public static DateTime ToDateTime(this Java.Util.Date date) { Java.Text.SimpleDateFormat format = new Java.Text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); return(DateTime.Parse(format.Format(date))); // return new DateTime(date.Year, date.Month, date.Day, date.Hours, date.Minutes, date.Seconds); }
private object getAllCallLogs(ContentResolver cr) { // reading all data in descending order according to DATE // String strOrder = android.provider.CallLog.Calls.DATE + " DESC"; string strOrder = string.Format("{0} desc ", CallLog.Calls.Date); Android.Net.Uri callUri = Android.Net.Uri.Parse("content://call_log/calls"); var cur = cr.Query(callUri, null, null, null, strOrder); // loop through cursor while (cur.MoveToNext()) { string callNumber = cur.GetString(cur .GetColumnIndex(CallLog.Calls.Number)); string callName = cur .GetString(cur .GetColumnIndex(CallLog.Calls.CachedName)); string callDate = cur.GetString(cur .GetColumnIndex(CallLog.Calls.Date)); Java.Text.SimpleDateFormat formatter = new Java.Text.SimpleDateFormat( "dd-MMM-yyyy HH:mm"); string dateString = formatter.Format(new Java.Sql.Date(Long .ParseLong(callDate))); string callType = cur.GetString(cur .GetColumnIndex(CallLog.Calls.Type)); string isCallNew = cur.GetString(cur .GetColumnIndex(CallLog.Calls.New)); string duration = cur.GetString(cur .GetColumnIndex(CallLog.Calls.Duration)); // process log data... } return(null); }
public List <SuBienApp.Models.Calls> GetCallLogs() { // filter in desc order limit by no string querySorter = string.Format("{0} desc ", CallLog.Calls.Date); List <SuBienApp.Models.Calls> calls = new List <SuBienApp.Models.Calls>(); // CallLog.Calls.ContentUri is the path where data is saved //ICursor queryData = Android.Content.ContentResolver.Query(CallLog.Calls.ContentUri, null, null, null, querySorter); try { Android.Database.ICursor queryData = ((Activity)Forms.Context).ManagedQuery(CallLog.Calls.ContentUri, null, null, null, querySorter); while (queryData.MoveToNext()) { string callNumber = queryData .GetString(queryData .GetColumnIndex(CallLog.Calls.Number)); string callName = queryData .GetString(queryData .GetColumnIndex(CallLog.Calls.CachedName)); string callDate = queryData .GetString(queryData .GetColumnIndex(CallLog.Calls.Date)); Java.Text.SimpleDateFormat formatter = new Java.Text.SimpleDateFormat( "dd/MMM/yyyy HH:mm"); DateTime dateString = Convert.ToDateTime(formatter.Format(new Java.Sql.Date(Long .ParseLong(callDate)))); string callType = queryData .GetString(queryData .GetColumnIndex(CallLog.Calls.Type)); string isCallNew = queryData .GetString(queryData .GetColumnIndex(CallLog.Calls.New)); string duration = queryData .GetString(queryData .GetColumnIndex(CallLog.Calls.Duration)); calls.Add(new SuBienApp.Models.Calls { CallName = callName + " Fecha: " + Convert.ToString(dateString, CultureInfo.InvariantCulture), Number = callNumber, Date = dateString, Duration = duration, }); } var lessdays = DateTime.Now.AddDays(-8); return(calls.Where(c => c.Date > lessdays).ToList());//.GroupBy(p=> new { p.CachedName,p.Date,p.Duration,p.Number}).Select(p=>new { p.Key.CachedName,p.Key.Date,p.Key.Duration,p.Key.Number}).ToList() ; } catch (System.Exception ex) { return(calls); } }
public DateTime JavaTimeToCSTime(Java.Util.Date dateTime) { Java.Text.SimpleDateFormat SDF = new Java.Text.SimpleDateFormat("dd/MM/yyyy h:mm:ss a"); string strSendDateTime = SDF.Format(dateTime); DateTime castSendDateTime = DateTime.ParseExact(strSendDateTime, "dd/MM/yyyy h:mm:ss tt", CultureInfo.InvariantCulture); return(castSendDateTime); }
public string MilisecondToDateTimeStr(long milTime, string pattern) { //날짜 표시 //string pattern = "yyyy-MM-dd HH:mm:ss"; Java.Text.SimpleDateFormat formatter = new Java.Text.SimpleDateFormat(pattern); string result = (string)formatter.Format(new Java.Sql.Timestamp(milTime)); return(result); }
public void OnMonthScroll(Date p0) { try { Java.Text.SimpleDateFormat dateFormat = new Java.Text.SimpleDateFormat("YYYY-MM-dd hh:mm:ss"); DateTime sa = Convert.ToDateTime(dateFormat.Format(p0)); tv.Text = sa.ToString("MMMM - yyyy"); string mStringLoginInfo = string.Empty; string mStringSessionToken = string.Empty; try { var objdb = new DBaseOperations(); var lstu = objdb.selectTable(); if (lstu != null && lstu.Count > default(int)) { var uobj = lstu.FirstOrDefault(); if (uobj.Password == " ") { throw new Exception("Please login again"); } mStringLoginInfo = uobj.EmailId; mStringSessionToken = uobj.AuthToken; } } catch { } var firstDayOfMonth = new DateTime(sa.Year, sa.Month, 1); try { cview.RemoveAllEvents(); //cview.AddEvents(new ActivityViewerFragment().LoadActivities(firstDayOfMonth.ToString("yyyy-MM-dd"), mStringSessionToken)); cview.AddEvents(superObj.LoadActivities(firstDayOfMonth.ToString("yyyy-MM-dd"), mStringSessionToken)); } catch { } } catch (Exception ex) { currentActivity.RunOnUiThread(() => { Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity); alertDiag.SetTitle(Resource.String.DialogHeaderError); alertDiag.SetMessage(ex.Message); alertDiag.SetIcon(Resource.Drawable.alert); alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) => { }); Dialog diag = alertDiag.Create(); diag.Show(); diag.SetCanceledOnTouchOutside(false); }); } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.scann); // Create your application here FindViewById <Spinner>(Resource.Id.spCustomer).ItemSelected += spinner_ItemSelected; Spinner spinner1er = FindViewById <Spinner>(Resource.Id.spCustomer); FindViewById <Button>(Resource.Id.button3).Click += Scan_Click; FindViewById <Button>(Resource.Id.button2).Click += Scan_Click1; Button button = FindViewById <Button>(Resource.Id.button1); timev = FindViewById <TextView>(Resource.Id.textViewtime); _yes = FindViewById <CheckBox>(Resource.Id.checkBox1); _no = FindViewById <CheckBox>(Resource.Id.checkBox2); scan_yes = FindViewById <CheckBox>(Resource.Id.checkBox3); scan_no = FindViewById <CheckBox>(Resource.Id.checkBox4); _dateDisplay = FindViewById <TextView>(Resource.Id.textView14); _yes.CheckedChange += _Yes_CheckedChange; _no.CheckedChange += _No_CheckedChange; scan_yes.CheckedChange += Scan_yes_CheckedChange; scan_no.CheckedChange += Scan_no_CheckedChange; await myMethod(); spinner1er.Adapter = adapter; button.Click += delegate { try { Java.Util.Date d = new Java.Text.SimpleDateFormat("yyyy-MM-dd H:mm:ss").Parse(_dateDisplay.Text + " " + timev.Text.TrimEnd('P', 'A', 'M', ' ')); // Java.Util.Date date = new Java.Util.Date(); // DateFormat dateFormat = Android.Text.Format.DateFormat.Format(,date); // mTimeText.setText("Time: " + dateFormat.format(date)); // var dateb = _dateDisplay.Text + " " + timev.Text; // DateTime dft = DateTime.ParseExact(dateb, "yyyy-MM-dd H:mm:ss", CultureInfo.InvariantCulture); Toast.MakeText(this, "assumed updated ", ToastLength.Short).Show(); dataconnection.upsdatescann(user, wind_scanned, d, scanned_complete); Finish(); } catch (Exception x) { Toast.MakeText(this, x.Message, ToastLength.Long).Show(); } }; }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.sla_offsite); // Create your application here FindViewById <Spinner>(Resource.Id.spCustomer).ItemSelected += spinner_ItemSelected; Spinner spinner1er = FindViewById <Spinner>(Resource.Id.spCustomer); FindViewById <Spinner>(Resource.Id.spinner1).ItemSelected += Leave_site_ItemSelected; Spinner commentsview = FindViewById <Spinner>(Resource.Id.spinner1); _comments = FindViewById <EditText>(Resource.Id.editText1); FindViewById <Button>(Resource.Id.button3).Click += Scan_Click; FindViewById <Button>(Resource.Id.button2).Click += Scan_Click1; Button button = FindViewById <Button>(Resource.Id.button1); timev = FindViewById <TextView>(Resource.Id.textViewtime); _dateDisplay = FindViewById <TextView>(Resource.Id.textView14); await myMethod(); InitializeLocationManagerAsync(); spinner1er.Adapter = adapter; button.Click += delegate { try { if (_local == 0.0) { Thread.Sleep(500); } Java.Util.Date d = new Java.Text.SimpleDateFormat("yyyy-MM-dd H:mm:ss").Parse(_dateDisplay.Text + " " + timev.Text.TrimEnd('P', 'A', 'M', ' ')); dataconnection.upsdatesiteout(row_id, _local, _local2, d, _comments.Text, 1); Toast.MakeText(this, "assumed updated ", ToastLength.Short).Show(); Finish(); } catch (Exception x) { Toast.MakeText(this, x.Message, ToastLength.Long).Show(); } }; }
private static Java.IO.File getOutputMediaFile() { string extr = Android.OS.Environment.ExternalStorageDirectory.ToString(); Java.IO.File mFolder = new Java.IO.File(extr + "/TMMFOLDER"); if (!mFolder.Exists()) { mFolder.Mkdir(); } String timeStamp = new Java.Text.SimpleDateFormat("yyyyMMdd_HHmmss", Locale.Default).Format(new Date()); Java.IO.File mediaFile; mediaFile = new Java.IO.File(mFolder.AbsolutePath + Java.IO.File.Separator + "IMG_" + timeStamp + ".jpg"); return(mediaFile); }
public String ToString(String format, IFormatProvider provider) { Contract.Ensures(Contract.Result <String>() != null); //return DateTimeFormat.Format(ClockDateTime, format, DateTimeFormatInfo.GetInstance(formatProvider), Offset); bool useInvariant; bool foundK; bool useUtc; string javaFormat = DateTimeFormatting.ToJavaFormatString(format, provider, m_dateTime.Kind, true, out useInvariant, out foundK, out useUtc); var locale = useInvariant ? CultureInfo.InvariantCulture.Locale : provider.ToLocale(); var sdf = new Java.Text.SimpleDateFormat(javaFormat, locale); var cal = GetCalendar(); sdf.TimeZone = cal.TimeZone; return(sdf.Format(cal.Time)); }
// Create a File for saving an image or video */ public static File GetOutputMediaFile(CaptureMode captureMode) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. File mediaStorageDir = new File(Android.OS.Environment.GetExternalStoragePublicDirectory( Android.OS.Environment.DirectoryPictures), "WeClip"); //// This location works best if you want the created images to be shared //// between applications and persist after your app has been uninstalled. // Create the storage directory if it does not exist if (!mediaStorageDir.Exists()) { if (!mediaStorageDir.Mkdirs()) { Log.Debug("CameraFileSave", "Failed to create directory."); return(null); } } string timeStamp = new Java.Text.SimpleDateFormat("yyyyMMdd_HHmmss").Format(new Java.Util.Date()); File mediaFile; if (captureMode == CaptureMode.Photo) { mediaFile = new File(mediaStorageDir.Path + File.Separator + "IMG_" + timeStamp + ".jpg"); } else if (captureMode == CaptureMode.Video) { mediaFile = new File(mediaStorageDir.Path + File.Separator + "VID_" + timeStamp + ".mp4"); } else { return(null); } return(mediaFile); }
// // Summary: // Converts the value of the current System.DateTime object to its equivalent // string representation using the specified format and culture-specific format // information. // // Parameters: // format: // A standard or custom date and time format string. // // provider: // An object that supplies culture-specific formatting information. // // Returns: // A string representation of value of the current System.DateTime object as // specified by format and provider. // // Exceptions: // System.FormatException: // The length of format is 1, and it is not one of the format specifier characters // defined for System.Globalization.DateTimeFormatInfo.-or- format does not // contain a valid custom format pattern. // // System.ArgumentOutOfRangeException: // The date and time is outside the range of dates supported by the calendar // used by provider. public string ToString(string format, IFormatProvider provider) { var sdf = new Java.Text.SimpleDateFormat(GetJavaFormat(format, provider), Locale.Default); sdf.TimeZone = TimeZone.GetTimeZone("UTC"); return sdf.Format(ToDate()); }