怎么获得一个日期的字符串阿!?不要long型阿要那种能看明白的日期类型阿谢谢大家了阿 怎么获得系统时间啊?不要这种格式阿System.currentTimeMillis() 要当前年+当前月+当前日+当前小时+当前分+当前秒+当前毫秒+当前微秒啊xxxx年+xx月+xx日+小时+分+秒+毫秒+微秒啊有办法吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");System.out.println(df.format(new Date())); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");System.out.println(df.format(new Date())); 呵呵,楼主看来是刚学java要多看书了,加油 /** * 将YYYYMMDD格式的串转换成YYYY-MM-DD格式,反函数为dateToStr * @param date YYYYMMDD格式的串 * * @return: YYYY-MM-DD格式的串 */ public static String strToDate(String date){ StringBuffer temp = new StringBuffer(); temp.append(date.substring(0,4)).append("-").append(date.substring(4,6)); temp.append( "-").append(date.substring(6,8)); return temp.toString(); } /** * 将YYYY-MM-DD格式的串转换成YYYYMMDD格式,反函数为strToDate * @param date YYYY-MM-DD格式的串 * * @return: YYYYMMDD格式的串 */ public static String dateToStr(String date){ StringBuffer temp = new StringBuffer(); temp.append(date.substring(0,4)).append(date.substring(5,7)); temp.append(date.substring(8,10)); return temp.toString(); } 楼上的不是多此一举吗,干吗不用SimpleDateFormat而且第二个dateToStr,只需要return date.replaceAll("-","")就可以了 谢谢 believefym(暮色,miss,迷失,miss) 啊!还能加上更小的时间单位吗?怎么写阿? 谢谢 believefym(暮色,miss,迷失,miss) 啊!还能加上更小的时间单位吗?怎么写阿? 谢谢 believefym(暮色,miss,迷失,miss) 啊!还能加上更小的时间单位吗?怎么写阿? 看了api,好像到毫秒级吧,微妙的不知道如何处理了 初学到 IO,不是很理解,求解! 可变参数,二维数组 有关工厂类的生存周期 用数据结构实现ArrayList 如何获取JTextPane中文本的行数 classloader相关基础知识 请大家看看这段CODE怎么不能正确执行! 用java编写一个完整的关于2D移动,旋转,错切,缩放等的程序,正确给200分 新手上路,请帮忙!谢谢! 在XP中MySQL老是启动不了,怎么办呢? 请各位兄弟,帮忙啊急啊 我想用JBuilder中文版
System.out.println(df.format(new Date()));
System.out.println(df.format(new Date()));
* 将YYYYMMDD格式的串转换成YYYY-MM-DD格式,反函数为dateToStr
* @param date YYYYMMDD格式的串
*
* @return: YYYY-MM-DD格式的串
*/
public static String strToDate(String date){
StringBuffer temp = new StringBuffer();
temp.append(date.substring(0,4)).append("-").append(date.substring(4,6));
temp.append( "-").append(date.substring(6,8));
return temp.toString();
} /**
* 将YYYY-MM-DD格式的串转换成YYYYMMDD格式,反函数为strToDate
* @param date YYYY-MM-DD格式的串
*
* @return: YYYYMMDD格式的串
*/
public static String dateToStr(String date){
StringBuffer temp = new StringBuffer();
temp.append(date.substring(0,4)).append(date.substring(5,7));
temp.append(date.substring(8,10));
return temp.toString();
}
而且第二个dateToStr,只需要return date.replaceAll("-","")就可以了
怎么写阿?
怎么写阿?
怎么写阿?