code: public static String formatDate (Date date, boolean useShorthand)
      {
          if (date == null) {
              return "";
          }
  
          Date now = new Date();
          if (getYear(date) != getYear(now)) {
              return _yfmt.format(date);
  
          } else if (getMonth(date) != getMonth(now)) {
              return _mfmt.format(date);
  
          } else if (useShorthand && getDayOfMonth(date) == getDayOfMonth(now)) {
              return _msgs.today();
  
          // these will break for one hour on daylight savings time and we'll instead report the date
          // in MMM dd format or we'll call two days ago yesterday for that witching hour; we don't
          // have excellent date services in the browser, so we're just going to be OK with that
          } else if (useShorthand && getDayOfMonth(date) ==
                     getDayOfMonth(new Date(now.getTime()-24*60*60*1000))) {
              return _msgs.yesterday();
  
          } else if (useShorthand && getDayOfMonth(date) ==
                     getDayOfMonth(new Date(now.getTime()+ONE_DAY))) {
              return _msgs.tomorrow();
  
          } else {
              return _mfmt.format(date);
          }
      }
docs: Formats the supplied date relative to the current time: Today, Yesterday, MMM dd, and
  finally MMM dd, YYYY. If date is null the empty string is returned.
  
  @param useShorthand if false, "Today" and "Yesterday" will not be used, only the month/day
  and month/day/year formats.