marți, 14 aprilie 2015

[OmniFaces utilities (2.0)] Get the time of the previous request associated with the current HTTP session, measured in epoch time


[OmniFaces utilities] The getSessionLastAccessedTime() method returns the time of the previous request associated with the current HTTP session, measured in epoch time. This implicitly creates the session if one doesn't exist.

Method:
Usage:

import org.omnifaces.util.Faces;
...
long time = Faces.getSessionLastAccessedTime();
// e.g. three checks, same session
// first check: Tue Apr 14 16:16:24 EEST 2015
// second check, after a few seconds: Tue Apr 14 16:16:28 EEST 2015
// third check, after a few more seconds: Tue Apr 14 16:16:35 EEST 2015
Date dateTile = new Date(time);                      

Niciun comentariu:

Trimiteți un comentariu