diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml index dee0634951..7e3b8cb280 100644 --- a/core-java-8/pom.xml +++ b/core-java-8/pom.xml @@ -99,6 +99,16 @@ joda-time ${joda.version} + + org.aspectj + aspectjrt + ${asspectj.version} + + + org.aspectj + aspectjweaver + ${asspectj.version} + @@ -170,6 +180,7 @@ 2.10 3.6.1 + 1.8.9 1.7.0 1.19 1.19 diff --git a/core-java-8/src/main/java/com/baeldung/aspect/ChangeCallsToCurrentTimeInMillisMethod.aj b/core-java-8/src/main/java/com/baeldung/aspect/ChangeCallsToCurrentTimeInMillisMethod.aj new file mode 100644 index 0000000000..b28bebfdaf --- /dev/null +++ b/core-java-8/src/main/java/com/baeldung/aspect/ChangeCallsToCurrentTimeInMillisMethod.aj @@ -0,0 +1,9 @@ +package com.baeldung.aspect; + +public aspect ChangeCallsToCurrentTimeInMillisMethod { + long around(): + call(public static native long java.lang.System.currentTimeMillis()) + && within(user.code.base.pckg.*) { + return 0; + } +} diff --git a/core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeUnitTest.java b/core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeUnitTest.java index 3ad3deb548..1689a5054d 100644 --- a/core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/util/CurrentDateTimeUnitTest.java @@ -1,6 +1,7 @@ package com.baeldung.util; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.time.Clock; import java.time.Instant; @@ -9,6 +10,8 @@ import java.time.LocalTime; import java.time.ZoneId; import java.time.temporal.ChronoField; +import org.joda.time.DateTime; +import org.joda.time.DateTimeUtils; import org.junit.Test; public class CurrentDateTimeUnitTest { @@ -39,5 +42,4 @@ public class CurrentDateTimeUnitTest { assertEquals(clock.instant().getEpochSecond(), now.getEpochSecond()); } - }