'Android - Firebase ServerValue.TIMESTAMP returns "{.sv=timestamp}"

I have to save ServerValue.TIMESTAMP in my Database but it must be a string. When I type String.valueOf(ServerValue.TIMESTAMP); or ServerValue.TIMESTAMP.toString(); it returs "{.sv=timestamp}". I want "1523084664300" instead of 1523084664300



Solution 1:[1]

ServerValue.TIMESTAMP is just a token that the server understands and translates to a number, which is the current time using its own clock. It doesn't have a numeric value on the client. If you want the current time in milliseconds on the client, then just use the client's native API to get that value: System.currentTimeMillis()

If you're trying to store numbers as strings in Realtime Database, don't. That's not a very good solution.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Doug Stevenson