I am using Spring Boot 2 for creating rest services. I am using @after aop to log some of user information who has accessed at the end. Here I want to log the user timezone, i.e. timezone of the client / consumer from which this api is called.
I am using below aspect method.
@Aspect
@Component
public class AuditAspect {
@Pointcut("@annotation(auditEvent)")
public void runAuditMethod(AuditEvent auditEvent) {}
@After("runAuditMethod(auditEvent)")
public void auditMethod(JoinPoint joinPoint, AuditEvent auditEvent) throws Throwable {
.... //get user timezone
}
}
When I did some research I see that I can use RequestContextUtils.getTimeZone(httpServletRequest)
to get the timezone. But is there a way I can get it in aop method?