下面是我的简单的日期码format.Where IAM越来越O/P为无法获取日期所需的SimpleDateFormat
2012-03-13
13:15:00-4:00
2012/03/13 13:15:00 +0530
但我需要格式的o/p MM/dd/yyyy HH:mm
public class Time {
public static void main(String args[]) throws ParseException
{
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat ti=new SimpleDateFormat("MM/dd/yyyy HH:mm");
SimpleDateFormat sdf1=new SimpleDateFormat("yyyy/MM/dd HH:mm:ss Z");
String dt= "2012-03-13T13:15:00-4:00";
String st[]=dt.split("T");
System.out.println(st[0]);
System.out.println(st[1]);
String time[]= st[1].split("-");
Date fromDt =(Date)sdf.parse(st[0]+" "+time[0]);
System.out.println(sdf1.format(fromDt));
}
}
是-0400是你的[Z时区(http://docs.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html#rfc822timezone)?或者它是-4(00)m(m):你想从给定日期减去的ss格式的时间量? – JMelnik 2012-03-13 12:56:36
其ia时区 – Pawan 2012-03-13 13:27:59