我正在尝试创建一个应用,用户必须输入日期,系统会显示此后经过了多长时间。但它给了我错误的时间。当我输入日期并按下按钮时,它会显示我:try
{
reader1 = new StreamReader(path1);
// if we got this far, path 1 succeded, so try path2
try
{
reader2 = new StreamReader(path2);
}
catch (OIException ex)
{
// Uh oh something went wrong with opening the file2 for reading
// Nevertheless, have a look at file1. Its fine!
}
}
catch (OIException ex)
{
// Uh oh something went wrong with opening the file1 for reading.
// So I didn't even try to open file2
}
以下是代码:
19/06/1989 21:39:32
我的代码中的错误在哪里?
答案 0 :(得分:0)
你的假设是错误的。您不能减去两个日期并期望日期。你的“差异”是一段时间。您必须手动将其转换为年,月,日等(或使用某些第三个库)。