How about printing the long into a StringBuilder, then insert a period at
StringBuilder.length() - 3?

On Thu, Mar 24, 2016 at 12:13 AM, Mikael Ståldal <[email protected]>
wrote:

> I am trying to make GelfLayout allocation free, and got stuck at timestamp
> formatting. GELF need the timestamp as number of seconds with milliseconds
> as decimals.
>
> E.g. 1458741206653 -> "1458741206.653"
>
> The current implementation (in GelfLayout.java) is obviously not
> allocation free:
>
> static CharSequence formatTimestamp(final long timeMillis) {
>     return new BigDecimal(timeMillis).divide(TIME_DIVISOR).toPlainString();
> }
>
> (see also unit test in GelfLayoutTest.java)
>
> Any ideas on how do fix this?
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> [email protected]
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>

Reply via email to