Parsing 可以用java解析以下日期和时间吗?
我将如何解析Parsing 可以用java解析以下日期和时间吗?,parsing,datetime,Parsing,Datetime,我将如何解析2013-12-20T00:45:00.000+05:30以分别获取日期和时间。这在IST中。 我能用计算机得到日期 SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); sdf.format(sdf1.parse(expirationDate) 但是我不知道如何获得时间 Timestamp
2013-12-20T00:45:00.000+05:30
以分别获取日期和时间。这在IST
中。
我能用计算机得到日期
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
sdf.format(sdf1.parse(expirationDate)
但是我不知道如何获得时间
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
Date date = new Date(timestamp.getTime());
// S is the millisecond
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy' 'HH:MM:ss:S");
System.out.println(simpleDateFormat.format(timestamp));
System.out.println(simpleDateFormat.format(date));
暂时
Date date = new Date(); // given date
Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
calendar.setTime(date); // assigns calendar to given date
calendar.get(Calendar.HOUR_OF_DAY); // gets hour in 24h format
calendar.get(Calendar.HOUR); // gets hour in 12h format
calendar.get(Calendar.MONTH); // gets month number, NOTE this is zero base
String expirationDate = "2013-12-20T00:45:00.000+05:30";
SimpleDateFormat string2DateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
SimpleDateFormat date2StringFormatter = new SimpleDateFormat("HH:mm:ss");
System.out.println(date2StringFormatter.format(string2DateFormatter.parse(expirationDate)));