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:

  1. The day of the week (like Monday)
  2. The day of the month (like 21)
  3. minutes (like April)
  4. Years (like 2014)
  5. Hours (such as 17)
  6. 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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -