编写一个程序,接受命令行参数输入的一个日期格式为YYYYMMDD的字符串,

[复制链接]
查看11 | 回复2 | 2011-11-15 13:25:13 | 显示全部楼层 |阅读模式
你好,我按照你的要求写的如下代码,可以直接运行import java.util.Calendar;import java.util.Scanner;public class test {public static void main(String[] args) {Scanner s = new Scanner(System.in);String str = s.next();s.close();if (str.length() != 8) {System.out.println("日期长度错误:" + str);return;}String yearStr = str.substrin...
回复

使用道具 举报

千问 | 2011-11-15 13:25:13 | 显示全部楼层
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行