获取时间点所在星期的周一

@param time 指定时间

@return 毫秒数
182339
public static long monday(long time) {
        ZoneId zid = ZoneId.systemDefault();
        Instant instant = Instant.ofEpochMilli(time);
        LocalDate ld = instant.atZone(zid).toLocalDate();
        ld = ld.minusDays(ld.getDayOfWeek().getValue() - 1);
        return ld.atStartOfDay(zid).toInstant().toEpochMilli();
    }
558210
public String getDate(long time) {

        return CmsDateUtil.getDate(new Date(time), DateFormat.SHORT, m_locale);
    }
1151360
public static String elasticSearchTimeFormatToISO8601(String time) {
        try {
            DateTime dt = DateTime.parse(time, ES_DATE_FORMAT_FORMATTER);
            return getISO8601String(dt);
        } catch (IllegalArgumentException e) {
            return time;
        }
    }
50153
protected static String fromTime(final long time) {
		Date date = new Date(time);
		// Waiting for Java 7: SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
		String formatted = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(date);
		return formatted.substring(0, 22) + ":" + formatted.substring(22);
	}
88065
public String getDateTime(long time) {

        return CmsDateTimeUtil.getDateTime(new Date(time), CmsDateTimeUtil.Format.SHORT);
    }
69264
public static Time parseTime(String time) {
        Assert.assertTrue("time is required, but value is empty", Checker.isNotEmpty(time));
        String[] times = time.split(ValueConsts.COLON);
        String timeStr = formatTimeString(times[0]) + ":" + (times.length > 1 ? formatTimeString(times[1]) : "00") +
                ":" + (times.length > 2 ? formatTimeString(times[2]) : "00");
        return new Time(DateUtil.parseTime(timeStr).getTime());
    }
973255
public static String prettyDateTime(String time) {
        if (time.length() < 12) return time;
        StringBuilder sb = new StringBuilder();
        sb.append(time.substring(0, 4)).append("-").append(time.substring(4, 6)).append("-").append(time.substring(6, 8));
        sb.append(" ").append(time.substring(8, 10)).append(":").append(time.substring(10, 12));
        return sb.toString();
    }
24679
public com.google.type.TimeOfDay getTime() {
    return time_ == null ? com.google.type.TimeOfDay.getDefaultInstance() : time_;
  }
1183912
public static long getDayEndTime(final long time) {
        final Calendar end = Calendar.getInstance();
        end.setTimeInMillis(time);
        final int year = end.get(Calendar.YEAR);
        final int month = end.get(Calendar.MONTH);
        final int day = end.get(Calendar.DATE);
        end.set(year, month, day, 23, 59, 59);
        end.set(Calendar.MILLISECOND, 999);

        return end.getTimeInMillis();
    }
853761
public static Time valueOf(String s) {
        int hour;
        int minute;
        int second;
        int firstColon;
        int secondColon;

        if (s == null) throw new java.lang.IllegalArgumentException();

        firstColon = s.indexOf(':');
        secondColon = s.indexOf(':', firstColon+1);
        if ((firstColon > 0) & (secondColon > 0) &
            (secondColon < s.length()-1)) {
            hour = Integer.parseInt(s.substring(0, firstColon));
            minute =
                Integer.parseInt(s.substring(firstColon+1, secondColon));
            second = Integer.parseInt(s.substring(secondColon+1));
        } else {
            throw new java.lang.IllegalArgumentException();
        }

        return new Time(hour, minute, second);
    }
1264322
public static String timeToString(long time) {
        int[] fields = timeToFields(time, null);
        int millis = fields[5];
        int hour = millis / MILLIS_PER_HOUR;
        millis = millis % MILLIS_PER_HOUR;
        int min = millis / MILLIS_PER_MINUTE;
        millis = millis % MILLIS_PER_MINUTE;
        int sec = millis / MILLIS_PER_SECOND;
        millis = millis % MILLIS_PER_SECOND;

        return String.format((Locale)null, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
                fields[0], fields[1] + 1, fields[2], hour, min, sec, millis);
    }
10525
private String convertTime(final long time) {
    final Date date = new Date(time);
    return FORMAT.format(date);
  }
1222124
private static long javaToDosTime(long time) {
        Date d = new Date(time);
        int year = d.getYear() + 1900;
        if (year < 1980) {
            return (1 << 21) | (1 << 16);
        }
        return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
               d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
               d.getSeconds() >> 1;
    }
83860
public static String toClock(long time)
	{

		long ttime = time;

		short miliseconds = (short) (ttime % 1000);
		ttime = ttime / 1000;

		short seconds = (short) (ttime % 60);
		ttime = ttime / 60;

		short minutes = (short) (ttime % 60);
		ttime = ttime / 60;

		short hours = (short) (ttime % 24);
		ttime = ttime / 24;

		short days = (short) (ttime % 7);
		short weeks = (short) (ttime / 7);

		StringBuilder s = new StringBuilder();

		s.append(((weeks * 7 + days) * 24 + hours) + ":");

		if (minutes < 10) {
			s.append('0');
		}
		s.append(minutes + ":");

		if (seconds < 10) {
			s.append('0');
		}
		s.append(seconds + ".");

		if (miliseconds < 100) {
			s.append('0');
		}
		if (miliseconds < 10) {
			s.append('0');
		}
		s.append(miliseconds);

		return s.toString();
	}
412329
public static String format36time(long time) {
        String time36 = Long.toString(time, 36);
        return time36.length() < 9 ? ("0" + time36) : time36;
    }
908077
synchronized public static String getHeaderDate(long time) {

        if (HEADER_DEFAULT.getTimeZone() != GMT_TIMEZONE) {
            // ensure GMT is used as time zone for the header generation
            HEADER_DEFAULT.setTimeZone(GMT_TIMEZONE);
        }

        return HEADER_DEFAULT.format(new Date(time));
    }
1247120
public static String getTimeAgo(final long time, final Locale locale) {
        final BeanManager beanManager = BeanManager.getInstance();
        final LangPropsService langService = beanManager.getReference(LangPropsService.class);
        final Map<String, String> langs = langService.getAll(locale);

        final long diff = System.currentTimeMillis() - time;
        long r;

        if (diff > YEAR_UNIT) {
            r = diff / YEAR_UNIT;

            return r + " " + langs.get("yearsAgoLabel");
        }

        if (diff > MONTH_UNIT) {
            r = diff / MONTH_UNIT;

            return r + " " + langs.get("monthsAgoLabel");
        }

        if (diff > WEEK_UNIT) {
            r = diff / WEEK_UNIT;

            return r + " " + langs.get("weeksAgoLabel");
        }

        if (diff > DAY_UNIT) {
            r = diff / DAY_UNIT;

            return r + " " + langs.get("daysAgoLabel");
        }

        if (diff > HOUR_UNIT) {
            r = diff / HOUR_UNIT;

            return r + " " + langs.get("hoursAgoLabel");
        }

        if (diff > MINUTE_UNIT) {
            r = diff / MINUTE_UNIT;

            return r + " " + langs.get("minutesAgoLabel");
        }

        return langs.get("justNowLabel");
    }