如何通过键盘接受日期格式如mm / dd / yyyy作为java程序的输入 [英] How can I accept the date format like mm/dd/yyyy through keyboard as an input to the java program

查看:270
本文介绍了如何通过键盘接受日期格式如mm / dd / yyyy作为java程序的输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个程序来验证输入日期格式。我必须通过键盘接受日期格式,如mm / dd / yyyy作为java程序的输入。请告诉我有关如何接受的建议数据



我尝试过:



我想尝试在我的程序中使用简单的日期格式类,但我无法获取数据,所以请帮助我。

解决方案

使用扫描程序类 [ ^ ]以字符串形式读取日期, DateFormat.parse [ ^ ]进行转换。

I am trying to write a program to validate input date format.In that I have to accept the date format like mm/dd/yyyy through keyboard as an input to the java program.so please tell me suggestions regarding how to accept the data

What I have tried:

I am trying to use simple date format class in my program but i am unable to get the data so please help me.

解决方案

Use the Scanner class[^] to read the date as a string, and DateFormat.parse[^] to convert it.


这篇关于如何通过键盘接受日期格式如mm / dd / yyyy作为java程序的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆