I need to format the date into a specific string.
I used SimpleDateFormat
class to format the date using the pattern "yyyy-MM-dd'T'HH:mm:ssZ
" it returns current date as
"2013-01-04T15:51:45+0530
" but I need as
"2013-01-04T15:51:45+05:30
".
Below is the coding used,
Calendar c = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.ENGLISH);
Log.e(C.TAG, "formatted string: "+sdf.format(c.getTime()));
Output: formatted string: 2013-01-04T15:51:45+0530
I need the format as 2013-01-04T15:51:45+05:30
just adding the colon in between gmt time.
Because I'm working on Google calendar to insert an event, it accepts only the required format which I have mentioned.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…