MCPcopy Index your code
hub / github.com/apache/groovy / getAgo

Method getAgo

src/main/java/groovy/time/Duration.java:146–162  ·  view source on GitHub ↗

Returns the date represented by this duration ago. @return the computed date

()

Source from the content-addressed store, hash-verified

144 * @return the computed date
145 */
146 @Override
147 public Date getAgo() {
148 final Calendar cal = Calendar.getInstance();
149
150 cal.add(Calendar.DAY_OF_YEAR, -this.getDays());
151 cal.add(Calendar.HOUR_OF_DAY, -this.getHours());
152 cal.add(Calendar.MINUTE, -this.getMinutes());
153 cal.add(Calendar.SECOND, -this.getSeconds());
154 cal.add(Calendar.MILLISECOND, -this.getMillis());
155
156 cal.set(Calendar.HOUR_OF_DAY, 0);
157 cal.set(Calendar.MINUTE, 0);
158 cal.set(Calendar.SECOND, 0);
159 cal.set(Calendar.MILLISECOND, 0);
160
161 return new Date(cal.getTimeInMillis());
162 }
163
164 /**
165 * Returns a helper for computing dates relative to now.

Callers

nothing calls this directly

Calls 8

getMillisMethod · 0.80
getInstanceMethod · 0.65
addMethod · 0.65
getDaysMethod · 0.45
getHoursMethod · 0.45
getMinutesMethod · 0.45
getSecondsMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected