@Test public void getStringOfPeriod() throws Exception { DateTime d = new DateTime(2016, 7, 7, 10, 11, 23, 123); Assert.assertEquals("15s", EsDailySnapshotInstance.getStringOfPeriod(d.minusSeconds(15).toDate(), d.toDate())); Assert.assertEquals("1m 15s", EsDailySnapshotInstance .getStringOfPeriod(d.minusMinutes(1).minusSeconds(15).toDate(), d.toDate())); Assert.assertEquals("2h 1m 15s", EsDailySnapshotInstance .getStringOfPeriod(d.minusHours(2).minusMinutes(1).minusSeconds(15).toDate(), d.toDate())); Assert.assertEquals("13D 2h 1m 15s", EsDailySnapshotInstance .getStringOfPeriod(d.minusDays(13).minusHours(2).minusMinutes(1).minusSeconds(15).toDate(), d.toDate())); Assert.assertEquals("11M 3D 2h 1m 15s", EsDailySnapshotInstance .getStringOfPeriod( d.minusMonths(11).minusDays(3).minusHours(2).minusMinutes(1).minusSeconds(15).toDate(), d.toDate())); Assert.assertEquals("1Y 2M 13D 2h 1m 15s", EsDailySnapshotInstance .getStringOfPeriod( d.minusYears(1).minusMonths(2).minusDays(13).minusHours(2).minusMinutes(1) .minusSeconds(15).toDate(), d.toDate())); }
public static final String getStringOfPeriod(Date begin, Date end) { Preconditions.checkArgument(begin.getTime() < end.getTime()); Period period = new Period(new DateTime(begin), new DateTime(end)); StringBuilder strBuilder = new StringBuilder(); appendFieldIfGreat(strBuilder, "Y", period.getYears()); appendFieldIfGreat(strBuilder, "M", period.getMonths()); appendFieldIfGreat(strBuilder, "D", period.getWeeks() * 7 + period.getDays()); appendFieldIfGreat(strBuilder, "h", period.getHours()); appendFieldIfGreat(strBuilder, "m", period.getMinutes()); appendFieldIfGreat(strBuilder, "s", period.getSeconds()); if (strBuilder.length() > 0) { strBuilder.setLength(strBuilder.length() - 1); } return strBuilder.toString(); }
EsDailySnapshotInstance implements EsDocument { public static final String getStringOfPeriod(Date begin, Date end) { Preconditions.checkArgument(begin.getTime() < end.getTime()); Period period = new Period(new DateTime(begin), new DateTime(end)); StringBuilder strBuilder = new StringBuilder(); appendFieldIfGreat(strBuilder, "Y", period.getYears()); appendFieldIfGreat(strBuilder, "M", period.getMonths()); appendFieldIfGreat(strBuilder, "D", period.getWeeks() * 7 + period.getDays()); appendFieldIfGreat(strBuilder, "h", period.getHours()); appendFieldIfGreat(strBuilder, "m", period.getMinutes()); appendFieldIfGreat(strBuilder, "s", period.getSeconds()); if (strBuilder.length() > 0) { strBuilder.setLength(strBuilder.length() - 1); } return strBuilder.toString(); } }
EsDailySnapshotInstance implements EsDocument { public static final String getStringOfPeriod(Date begin, Date end) { Preconditions.checkArgument(begin.getTime() < end.getTime()); Period period = new Period(new DateTime(begin), new DateTime(end)); StringBuilder strBuilder = new StringBuilder(); appendFieldIfGreat(strBuilder, "Y", period.getYears()); appendFieldIfGreat(strBuilder, "M", period.getMonths()); appendFieldIfGreat(strBuilder, "D", period.getWeeks() * 7 + period.getDays()); appendFieldIfGreat(strBuilder, "h", period.getHours()); appendFieldIfGreat(strBuilder, "m", period.getMinutes()); appendFieldIfGreat(strBuilder, "s", period.getSeconds()); if (strBuilder.length() > 0) { strBuilder.setLength(strBuilder.length() - 1); } return strBuilder.toString(); } EsDailySnapshotInstance(); @JsonCreator  EsDailySnapshotInstance(@JsonProperty("config") EsInstanceConfig config);  EsDailySnapshotInstance(PinterestEsInstance esInstance); }
EsDailySnapshotInstance implements EsDocument { public static final String getStringOfPeriod(Date begin, Date end) { Preconditions.checkArgument(begin.getTime() < end.getTime()); Period period = new Period(new DateTime(begin), new DateTime(end)); StringBuilder strBuilder = new StringBuilder(); appendFieldIfGreat(strBuilder, "Y", period.getYears()); appendFieldIfGreat(strBuilder, "M", period.getMonths()); appendFieldIfGreat(strBuilder, "D", period.getWeeks() * 7 + period.getDays()); appendFieldIfGreat(strBuilder, "h", period.getHours()); appendFieldIfGreat(strBuilder, "m", period.getMinutes()); appendFieldIfGreat(strBuilder, "s", period.getSeconds()); if (strBuilder.length() > 0) { strBuilder.setLength(strBuilder.length() - 1); } return strBuilder.toString(); } EsDailySnapshotInstance(); @JsonCreator  EsDailySnapshotInstance(@JsonProperty("config") EsInstanceConfig config);  EsDailySnapshotInstance(PinterestEsInstance esInstance); static final Date roundToSeconds(Date dt); static final String getStringOfPeriod(Date begin, Date end); String getRegion(); void setRegion(String region); String getLocation(); void setLocation(String location); String getNodePool(); void setNodePool(String nodePool); String getState(); void setState(String state); String getDeployment(); void setDeployment(String deployment); Date getLaunchTime(); void setLaunchTime(Date launchTime); String[] getServiceMappings(); void setServiceMappings(String[] serviceMappings); String[] getServiceTag(); void setServiceTag(String[] serviceTag); String[] getSysTag(); void setSysTag(String[] sysTag); String[] getUsageTag(); void setUsageTag(String[] usageTag); List<String> getSecurityGroups(); void setSecurityGroups(List<String> securityGroups); String getLifecycle(); void setLifecycle(String lifecycle); String getType(); void setType(String type); String getName(); void setName(String name); Date getTerminateTime(); void setTerminateTime(Date terminateTime); String getRunTime(); void setRunTime(String runTime); String getId(); void setId(String id); long getVersion(); void setVersion(long version); @JsonProperty("config") void setConfig(Map<String, Object> foo); Map<String, Object[]> findDiff(EsDailySnapshotInstance inst); }
EsDailySnapshotInstance implements EsDocument { public static final String getStringOfPeriod(Date begin, Date end) { Preconditions.checkArgument(begin.getTime() < end.getTime()); Period period = new Period(new DateTime(begin), new DateTime(end)); StringBuilder strBuilder = new StringBuilder(); appendFieldIfGreat(strBuilder, "Y", period.getYears()); appendFieldIfGreat(strBuilder, "M", period.getMonths()); appendFieldIfGreat(strBuilder, "D", period.getWeeks() * 7 + period.getDays()); appendFieldIfGreat(strBuilder, "h", period.getHours()); appendFieldIfGreat(strBuilder, "m", period.getMinutes()); appendFieldIfGreat(strBuilder, "s", period.getSeconds()); if (strBuilder.length() > 0) { strBuilder.setLength(strBuilder.length() - 1); } return strBuilder.toString(); } EsDailySnapshotInstance(); @JsonCreator  EsDailySnapshotInstance(@JsonProperty("config") EsInstanceConfig config);  EsDailySnapshotInstance(PinterestEsInstance esInstance); static final Date roundToSeconds(Date dt); static final String getStringOfPeriod(Date begin, Date end); String getRegion(); void setRegion(String region); String getLocation(); void setLocation(String location); String getNodePool(); void setNodePool(String nodePool); String getState(); void setState(String state); String getDeployment(); void setDeployment(String deployment); Date getLaunchTime(); void setLaunchTime(Date launchTime); String[] getServiceMappings(); void setServiceMappings(String[] serviceMappings); String[] getServiceTag(); void setServiceTag(String[] serviceTag); String[] getSysTag(); void setSysTag(String[] sysTag); String[] getUsageTag(); void setUsageTag(String[] usageTag); List<String> getSecurityGroups(); void setSecurityGroups(List<String> securityGroups); String getLifecycle(); void setLifecycle(String lifecycle); String getType(); void setType(String type); String getName(); void setName(String name); Date getTerminateTime(); void setTerminateTime(Date terminateTime); String getRunTime(); void setRunTime(String runTime); String getId(); void setId(String id); long getVersion(); void setVersion(long version); @JsonProperty("config") void setConfig(Map<String, Object> foo); Map<String, Object[]> findDiff(EsDailySnapshotInstance inst);  }