如何通过键盘接受日期格式如mm / dd / yyyy作为java程序的输入

编程入门 行业动态 更新时间:2024-10-07 22:21:00
本文介绍了如何通过键盘接受日期格式如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程序的输入

本文发布于:2023-11-28 08:14:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641626.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:键盘   日期   格式   程序   java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!