android - Converting strings to date and time and extract year, month, day, day of week, hour and minutes -
I am retrieving JSN objects on my Android app. They have two fields: date and
time . On Layout, I need to remove the following string from these two fields:
- The day of the week (like Monday)
- The day of the month (like 21)
- minutes (like April)
- Years (like 2014)
- Hours (such as 17)
- Minutes (e.g. 35)
fields are date = "2014-04-21", time = "17:35:00"
How can I do this?
A class is SimpleDateFormat that parses the date and when you specify
Here is an example of your problems:
string string = "2014-04-21 17:35:00"; Calendar calendar = calendar.justinstance (); Calender.setTime (new Simple Format ("yyyy-MM-d k: m: s"). Pars (string)); System.out.println ("Day of the week:" + calendar.get (Calendar. DAY_OF_WEEK)); // 2 Monday System.out.println ("Day of the month:" + Calendar.Gate (Calendar DAY_OF_MONTH)); System.out.println ("Month:" + calendar.get (calendar. MONTH); // January 3 is april System.out.println ("year:" + calender.get (calendar.IEER)); System.out.println ("Hour:" + Calendar.Gate (calendar.HOUR_OF_DAY)); System.out.println ("min:" + calender.get (calendar.mind.tv); Where string is the string result of your json
Comments
Post a Comment