能不能讲日期转换成整数啊 能不能将日期形式的字符串转成整数如:String str = "2005-03-10";请前辈们指教啊~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以的 但 - 是不能转成 整数 你用 split(“-”)分割成字符串数组 ,用 Integer.ValueOf(str);就行了 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); try { calendar.setTime(sdf.parse("2005-03-10")); System.out.println(calendar.get(Calendar.YEAR)); } catch (ParseException e) { e.printStackTrace(); }年 月 日 依次取就是了 字符串分割,然后加到StringBuffer中 str =str.replaceAll("-","");Long long = Long.parseLong(str); JAVA方法返回一个对象,让我有点迷惑 中文日期格式问题 数据库查找数据,用Iterator遍历数据发现的问题 如何写.tld文件 急问:java程序写文件时遇到的问题??? 求救递归方法有错!!!!!!!!急 请问大侠们在java中如何将阳历转换为阴历? 文件拷贝问题 超连接中的中文问题! 请将以下两个打印的方法合并成为一个方法 一道java面试题,求解!! 线程join()方法无用问题
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
try {
calendar.setTime(sdf.parse("2005-03-10"));
System.out.println(calendar.get(Calendar.YEAR));
} catch (ParseException e) {
e.printStackTrace();
}年 月 日 依次取就是了
str =str.replaceAll("-","");
Long long = Long.parseLong(str);