??Java 8?????????????
???????????? ???????[ 2014/12/16 14:13:51 ] ????????Java API ???????
public enum TimePeriod
{
MINUTE(Dimension.MINUTE??
(from??
to) -> Minutes.minutesBetween(from?? to).getMinutes() + 1??
Minutes::minutes??
from -> from.withZone(DateTimeZone.UTC)
.withSecondOfMinute(0)
.withMillisOfSecond(0))??
HOUR(Dimension.HOUR??
(from??
to) -> Hours.hoursBetween(from?? to).getHours() + 1??
Hours::hours??
from -> from.withZone(DateTimeZone.UTC)
.withMinuteOfHour(0)
.withSecondOfMinute(0)
.withMillisOfSecond(0))??
DAY(Dimension.DAY??
(from??
to) -> Days.daysBetween(from?? to).getDays() + 1??
Days::days??
from -> from.withZone(DateTimeZone.UTC)
.withTimeAtStartOfDay())??
WEEK(Dimension.WEEK??
(from??
to) -> Weeks.weeksBetween(from?? to).getWeeks() + 1??
Weeks::weeks??
from -> from.withZone(DateTimeZone.UTC)
.withDayOfWeek(1)
.withTimeAtStartOfDay())??
MONTH(Dimension.MONTH??
(from??
to) -> Months.monthsBetween(from?? to).getMonths() + 1??
Months::months??
from -> from.withZone(DateTimeZone.UTC)
.withDayOfMonth(1)
.withTimeAtStartOfDay());
private Dimension<Timestamp> dimension;
private BiFunction<DateTime?? DateTime?? Integer> getNumberOfPoints;
private Function<Integer?? ReadablePeriod> getPeriodFromNbOfInterval;
private Function<DateTime?? DateTime> getStartOfInterval;
private TimePeriod(Dimension<Timestamp> dimension??
BiFunction<DateTime?? DateTime?? Integer> getNumberOfPoints??
Function<Integer?? ReadablePeriod> getPeriodFromNbOfInterval??
Function<DateTime?? DateTime> getStartOfInterval)
{
this.dimension = dimension;
this.getNumberOfPoints = getNumberOfPoints;
this.getPeriodFromNbOfInterval = getPeriodFromNbOfInterval;
this.getStartOfInterval = getStartOfInterval;
}
public Dimension<Timestamp> getDimension()
{
return dimension;
}
public int getNumberOfPoints(DateTime from??
DateTime to)
{
return getNumberOfPoints.apply(from?? to);
}
public ReadablePeriod getPeriodFromNbOfInterval(int nbOfInterval)
{
return getPeriodFromNbOfInterval.apply(nbOfInterval);
}
public DateTime getStartOfInterval(DateTime from)
{
return getStartOfInterval.apply(from);
}
}
????????????????????????????????????????????????????Ρ?
??????????????????
????for (int i = 0; i <= Days.daysBetween(from?? to).getDays(); i++)
????????????????
????for (int i = 0; i < timePeriod.getNumberOfPoints(from?? to); i++)
???????getGraphDataPoints?????Usage Analytics??????????????????????????Ρ????????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11