如何判断传过来的参数是否是时间类型

如何判断传过来的参数是否是时间类型,第1张

DateTime StartTime = ConvertToDateTime(DateTimeNowToShortDateString());

string StrSelect = RequestForm["dtSelect"]ToString();

SearchInfoStartTime =StrSelect;

if (SearchInfoStartTime != "")

{

if (!(DateTimeTryParse(SearchInfoStartTime, out StartTime))) //同理其他类型也可如法炮制的进行判断

{

SearchInfoStartTime = "2012-1-4";

}

}

Date currDate = CalendargetInstance()getTime();

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String dateTime = sdfformat(currDate);

dateTime即你需要获取的时间,格式为:yyyy-MM-dd HH:mm:ss。

望采纳。。。

以上就是关于如何判断传过来的参数是否是时间类型全部的内容,包括:如何判断传过来的参数是否是时间类型、Servlet获取时间,详见补充,有加分哦!、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9421203.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存