请教一个时间转换的问题 String time = "20081210162639";//所有时间都是这种格式表示年月日小时分秒想转成 2008-12-10 16:26:39,该如何转啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 String time = "20081210162639"; StringBuffer time2=new StringBuffer(time); String time3 = new String( time2.substring(0, 3)+"-" + time2.substring(4,5 )+"-" + time2.substring(6, 7)+" " + time2.substring(8, 9)+":" + time2.substring(10, 11)); 刚才有点细节问题 呵呵,现在对了 String time = "20081210162639"; StringBuffer time2=new StringBuffer(time); String time3 = new String( time2.substring(0, 4)+"-" + time2.substring(4,6 )+"-" + time2.substring(6, 8)+" " + time2.substring(8, 10)+":" + time2.substring(10, 12)+":" + time2.substring(12, 14)); System.out.println(time3); DateFormat(now(),"yyyy-mm-dd hh:mm:ss") 使用DateFormat SimpleDateFormat date = new SimpleDateFormat("yyyy.MM.dd"); String receivedTime = date.format(new Date(System.currentTimeMillis())); receivedTime = receivedTime.replaceAll("\\.", ""); System.out.println(receivedTime); String a = "2008.11.24"; String b = "2008.10.11"; a =a.replaceAll("\\.", ""); b= b.replaceAll("\\.", ""); System.out.println(a+" ss "+b);楼主 看看这个 Date date= new SimpleDateFormat("yyyy/MM/dd/hh/mm/ss"); package org.leelin.common;import java.text.SimpleDateFormat;import java.util.Date;public class DateTester { /** * @param args */ public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub String date="20081210162639"; SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss"); Date d=sdf.parse(date); SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd日 HH-mm-ss"); String formatDate=sdf2.format(d); System.out.println(formatDate); }} 把SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");换成SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String time = "20081210162639";SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");System.out.println(df.parse(time).toLocaleString()); 谁能帮我解释一下这个递归方法 程序代码的一个小问题? java正则表达式问题..新人在线求帮助 新手求助! short s1 = 1; s1 = s1 + 1; (s1+1运算结果是int型,需要强制转换类型) String对象的问题,有点晕 新手求救,环境配置问题(急!) 用USB口连接手机,,如何用电脑控制手机给一个号码发短信!! 求这道题的答案 关于protected的问题。 求一个正则表达式: 空格不能连续 怎么把窗體寫成子父窗體啊
StringBuffer time2=new StringBuffer(time);
String time3 = new String( time2.substring(0, 3)+"-" +
time2.substring(4,5 )+"-" +
time2.substring(6, 7)+" " +
time2.substring(8, 9)+":" +
time2.substring(10, 11));
现在对了 String time = "20081210162639";
StringBuffer time2=new StringBuffer(time);
String time3 = new String( time2.substring(0, 4)+"-" +
time2.substring(4,6 )+"-" +
time2.substring(6, 8)+" " +
time2.substring(8, 10)+":" +
time2.substring(10, 12)+":" +
time2.substring(12, 14));
System.out.println(time3);
使用DateFormat
System.out.println(receivedTime);
String a = "2008.11.24";
String b = "2008.10.11";
a =a.replaceAll("\\.", "");
b= b.replaceAll("\\.", "");
System.out.println(a+" ss "+b);楼主 看看这个
package org.leelin.common;import java.text.SimpleDateFormat;
import java.util.Date;public class DateTester { /**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
String date="20081210162639";
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
Date d=sdf.parse(date);
SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd日 HH-mm-ss");
String formatDate=sdf2.format(d);
System.out.println(formatDate);
}}
换成SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
System.out.println(df.parse(time).toLocaleString());