简体   繁体   English

Xamarin.IOS日期格式

[英]Xamarin.IOS date format

I am currently working on a app which should be able to scan some codes, QR etc. 我目前正在开发一款应能够扫描某些代码,QR等的应用程序。

However when I am scanning a VEVENT code the date format is looking like this: 但是,当我扫描VEVENT代码时,日期格式如下所示:

20140713T190000Z 20140713T190000Z

My question is basicly how I can convert this into a normal DateTime which I can use to add events to the calender? 我的问题基本上是如何将其转换为可用于向日历添加事件的普通DateTime?

Thanks in advance 提前致谢

Try this for c# 试试这个为C#

NSDateFormatter dateFormat = new NSDateFormatter();
dateFormat.DateFormat = "d MMM yyyy";  
dateFormat.ToString(picker.Date);

use DateTime.ParseExact 使用DateTime.ParseExact

DateTime d = DateTime.ParseExact("20140713T190000Z","yyyyMMdd'T'HHmmss'Z'",null);

also see this question 也看到这个问题

use following code: 使用以下代码:

NSDate *currDate = [NSDate date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"dd.MM.YY HH:mm:ss"];
    NSString *dateString = [dateFormatter stringFromDate:currDate];

    yourLabel.text=dateString;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM