Java中是否有检查日期正确的API函数

luckyicer 2003-08-26 09:26:06
自己编也很简单,但是我想如果有像VB中isDate(strDate)这样的函数,就可以直接用了!
...全文
38 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
fft123 2003-08-26
  • 打赏
  • 举报
回复
trim是去两头的
全去的话可以用replace,把空格替换成空字符
zcjl 2003-08-26
  • 打赏
  • 举报
回复
trim
luckyicer 2003-08-26
  • 打赏
  • 举报
回复
另外去除空格的函数是什么,,,,,,,,,,,谢谢
fft123 2003-08-26
  • 打赏
  • 举报
回复
不可能吧??
你的是什么jdk??

public Date parse(String text,
ParsePosition pos)
Parses text from a string to produce a Date.
The method attempts to parse text starting at the index given by pos. If parsing succeeds, then the index of pos is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed date is returned. The updated pos can be used to indicate the starting point for the next call to this method. If an error occurs, then the index of pos is not changed, the error index of pos is set to the index of the character where the error occurred, and null is returned.


luckyicer 2003-08-26
  • 打赏
  • 举报
回复
SimpleDateFormat类没有parse方法阿。。。。。。。。。。
ChDw 2003-08-26
  • 打赏
  • 举报
回复
使用SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
sdf.parse(strDate);如果成功返回就是正确的string了

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧