高分请教(100),在线等!!!! 自己分别取出年月日的实际值再放到Date对象中啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DataFormat.parse()好像解不了中文字符吧,还是自己写方法实现罗 import java.text.*;import java.util.*;public class DateFormatTest { public static void main(String[] args) { Locale locale = Locale.CHINESE; DateFormat formatter = new SimpleDateFormat("yyyy年mm月dd日", locale); try{ Date date = (Date)formatter.parse("2005年1月6日"); System.out.println(date); int a = 10; } catch (ParseException e) { } }} DateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");Date d=sdf.parse("2005年01月6日"); 注意:M:表示月份 Month m:表示分钟 minute import java.util.Date;import java.util.Locale;import java.text.DateFormat;public class MyDate{ public static void main(String[] args) throws Exception{ String adate = "2005年1月6日"; DateFormat df = DateFormat.getDateInstance( DateFormat.LONG, Locale.SIMPLIFIED_CHINESE);//CHINA CHINESE Date d = df.parse(adate);// System.out.println(df.format(d)); int day = d.getDate(); int month = d.getMonth(); int year = d.getYear(); System.out.println("year=" + year + " month=" + month + " day=" + day); String odate = "2005/1/6"; d = new Date(odate); day = d.getDate(); month = d.getMonth(); year = d.getYear(); System.out.println("year=" + year + " month=" + month + " day=" + day); }} DateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");Date d=sdf.parse("2005年01月6日"); Java中的匿名内部类如何与外部类交互? Java的异常堆栈结构是什么样的?如何根据异常堆栈输出找到错误的位置? 大家帮我看看 我的程序是不是内存泄露了 给一个中文字符串 utf8编码后的 byte[] ,使用io流转成gbk编码的byte[],怎么弄 关于继承的疑惑 new Class[]{int.class}是什么意思? 请问,哪里有swt/JFace的api帮助文档下载 关于日期的一个问题,请各位帮忙 简单问题,关于路径设置 菜鸟,java的运行问题 散分啦 散分啦 很简单的小问题 关于AXIS对象串行化问题?
import java.util.*;
public class DateFormatTest { public static void main(String[] args) {
Locale locale = Locale.CHINESE; DateFormat formatter = new SimpleDateFormat("yyyy年mm月dd日", locale); try{
Date date = (Date)formatter.parse("2005年1月6日");
System.out.println(date);
int a = 10;
}
catch (ParseException e) {
}
}
}
Date d=sdf.parse("2005年01月6日");
M:表示月份 Month
m:表示分钟 minute
import java.util.Locale;
import java.text.DateFormat;public class MyDate{
public static void main(String[] args) throws Exception{
String adate = "2005年1月6日";
DateFormat df = DateFormat.getDateInstance(
DateFormat.LONG, Locale.SIMPLIFIED_CHINESE);//CHINA CHINESE
Date d = df.parse(adate);
// System.out.println(df.format(d));
int day = d.getDate();
int month = d.getMonth();
int year = d.getYear();
System.out.println("year=" + year + " month=" + month + " day=" + day); String odate = "2005/1/6";
d = new Date(odate);
day = d.getDate();
month = d.getMonth();
year = d.getYear();
System.out.println("year=" + year + " month=" + month + " day=" + day);
}
}
Date d=sdf.parse("2005年01月6日");