title: Android in date write today yesterday 2 days ago like that
body: <p>I need to print date like today,Yesterday,2 days ago like that for that i have done
  I am getting date like : <code>String date1 = "Thu Nov 13 19:01:25 GMT+05:30 2014";</code>
  calling like <code>str=get_userTime(date1);</code></p>
  
  <pre><code>private String get_userTime(String usertime) {
          Date d = null;
  
          // String datee = "Thu Nov 13 19:01:25 GMT+05:30 2014";
          String datee = usertime;
          SimpleDateFormat inputFormat = new SimpleDateFormat(
                  "EE MMM dd HH:mm:ss zz yyy");
  
          try {
              d = inputFormat.parse(datee);
          } catch (java.text.ParseException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          SimpleDateFormat outputFormat1 = new SimpleDateFormat("MM/dd/yyyy");
          System.out.println(outputFormat1.format(d));
           op = outputFormat1.format(d);
          op=formatToYesterdayOrToday(op);
          return op;
  
      }
  </code></pre>
  
  <p>and this is another function to get yesterday/today i have use this <a href="https://stackoverflow.com/questions/4292139/simplify-replacement-of-date-object-with-today-and-yesterday-strings-in-java">Link</a></p>
  
  <pre><code>public static String formatToYesterdayOrToday(String date) {
          date=op;
          DateTime dateTime = DateTimeFormat.forPattern("EEE hh:mma MMM d, yyyy")
                  .parseDateTime(date);
          DateTime today = new DateTime();
          DateTime yesterday = today.minusDays(1);
          DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("hh:mma");
  
          if (dateTime.toLocalDate().equals(today.toLocalDate())) {
              return "Today " + timeFormatter.print(dateTime);
          } else if (dateTime.toLocalDate().equals(yesterday.toLocalDate())) {
              return "Yesterday " + timeFormatter.print(dateTime);
          } else {
              return date;
          }
      }
  </code></pre>
  
  <p>But getting Error:</p>
  
  <pre><code>11-21 13:12:10.626: E/AndroidRuntime(20654): java.lang.IllegalArgumentException: Invalid format: "11/21/2014"
  11-21 13:12:10.626: E/AndroidRuntime(20654):    at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:871)
  </code></pre>
  
  <p>On </p>
  
  <pre><code>DateTime dateTime = DateTimeFormat.forPattern("EEE hh:mma MMM d, yyyy")
                  .parseDateTime(date); //In (formatToYesterdayOrToday())
  </code></pre>
  
  <p>I have used Joda-time.jar</p>