【发布时间】:2018-06-29 23:14:17
【问题描述】:
您好,我收到一个日期格式为 yyyy-MM-dd 的字符串,但我想将其与格式 dd-MM-yyyy 进行比较,以防万一不一样,当然不一样,我想转换它,对我来说问题不是转换,而是比较两种格式...... 所以我想可能是这样的
var dt = obj.date; //this a string
if (dt.formatDateorsomethingIguess == "dd/MM/yyyy") //this is the part I'm asking for
{
usedt(dt);
}
else
{
DateTime dt_format = DateTime.ParseExact(dt.Trim(), "dd-MM-yyyy",
System.Globalization.CultureInfo.InvariantCulture);
usedt(dt_format);
}
【问题讨论】:
-
是的,它是一个字符串@RufusL
-
这里有多少种格式有问题?就是你提到的那两个
标签: c# date xamarin.forms format