title: GWT - Convert Date formatting
body: <p>I have following method: </p>
  
  <pre><code>public static String formatDate(Date date) {
      Calendar calendar = Calendar.getInstance();
      calendar.setTime(date);
      Calendar today = Calendar.getInstance();
      Calendar yesterday = Calendar.getInstance();
      yesterday.add(Calendar.DATE, -1);
      DateFormat timeFormatter = new SimpleDateFormat("hh:mma");
      DateFormat dateTimeFormatter = new SimpleDateFormat("MMM d, yyyy - hh:mma");
  
      if (calendar.get(Calendar.YEAR) == today.get(Calendar.YEAR) &amp;&amp; calendar.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR) &amp;&amp; calendar.get(Calendar.HOUR_OF_DAY) == today.get(Calendar.HOUR_OF_DAY) &amp;&amp; calendar.get(Calendar.MINUTE) == today.get(Calendar.MINUTE)) {
          return "few seconds ago ";
      } else if (calendar.get(Calendar.YEAR) == today.get(Calendar.YEAR) &amp;&amp; calendar.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR) &amp;&amp; calendar.get(Calendar.HOUR_OF_DAY) == today.get(Calendar.HOUR_OF_DAY)) {
          return "few minutes ago ";
      } else if (calendar.get(Calendar.YEAR) == today.get(Calendar.YEAR) &amp;&amp; calendar.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)) {
          return "today " + timeFormatter.format(date);
      } else if (calendar.get(Calendar.YEAR) == yesterday.get(Calendar.YEAR) &amp;&amp; calendar.get(Calendar.DAY_OF_YEAR) == yesterday.get(Calendar.DAY_OF_YEAR)) {
          return "yesterday " + timeFormatter.format(date);
      } else {
          return dateTimeFormatter.format(date);
      }
  }
  </code></pre>
  
  <p>How do I write this in client side GWT?</p>