In that case you may need to surround that logic with a check that the long
value exceeds 999. Could this ever happen though?

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

> That seems to work. The only issue is that it doesn't handle values < 999
> (that will be "0" now), but perhaps that's acceptable?
>
> See GelfLayout.java
>
> On Wed, Mar 23, 2016 at 4:37 PM, Remko Popma <[email protected]>
> wrote:
>
>> 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.
>>>
>>
>>
>
>
> --
> [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