获取日期或时间只是从一个DateTime对象是从、对象、日期、时间

2023-09-03 04:42:08 作者:落败的青春

我有一个的DateTime 例如,有一个日期和时间。 我如何只提取日期或只是时间?

解决方案

  VAR天= value.Date; //日期时间,这将只是整个天
VAR时间= value.TimeOfDay; //时间跨度是持续时间到天
 

I have a DateTime instance that has a Date and a Time. How do I extract only the date or only the time?

解决方案 时间类 JDK7,8

var day = value.Date; // a DateTime that will just be whole days
var time = value.TimeOfDay; // a TimeSpan that is the duration into the day

 
精彩推荐
图片推荐