Search code examples
javadatetimeservletshttprequestlocaltime

is it possible to determine local time of the machine from which an api request is made?


I want to know the current time of the machine from which a request is made to my api written in java. Is it possible to do that using some function of HttpServletRequest?


Solution

  • No! Not using the java api request as requests are created by users .But if you have a UI application sending requests to java application that application can get the client machine's date & your Ui code can send this date in request.

    var currentDate = new Date();

    you can format and send the date now to server.