Exemple #1
0
 /**
  * 格式化日期
  *
  * @param date
  * @return
  */
 public String formatDate(Date date) {
   String dateStr = "";
   if (date != null) {
     PrettyTime prettyTime = new PrettyTime(Locale.CHINA);
     dateStr = prettyTime.format(date);
   }
   return dateStr.replace(" ", "");
 }
 /**
  * Return readable string of time different compare between 'then' and current time e.g 10 minutes
  * ago, 1 hour ago
  *
  * @param from
  * @param then
  * @return
  */
 public static String getHowLongAgoDescription(Date then) {
   Locale locale = Locale.getDefault();
   PrettyTime p = new PrettyTime(locale);
   return p.formatUnrounded(then);
 }
Exemple #3
0
 public String getLastUpdateStr() {
   PrettyTime p = new PrettyTime(new Locale("zh"));
   return p.format(this.updateTime) + "更新";
 }
 public static final String prettyTime(long millisecond) {
   PrettyTime p = new PrettyTime();
   return p.format(new Date(millisecond));
 }
 /**
  * 美化时间 如显示为 1小时前 2分钟前
  *
  * @return
  */
 public static final String prettyTime(Date date) {
   PrettyTime p = new PrettyTime();
   return p.format(date);
 }
Exemple #6
0
 public static String beautyTime(Date createTime) {
   PrettyTime pt = new PrettyTime(Locale.CHINA);
   return pt.format(createTime);
 }