Java Time Format formatSample(final int aValue, final long aTimestamp)

Here you can find the source of formatSample(final int aValue, final long aTimestamp)

Description

Formats the given value and timestamp into a single sample string.

License

Open Source License

Parameter

Parameter Description
aValue the sample value to format;
aTimestamp the timestamp to format.

Return

the sample string, in the form of <value16>@<timestamp10>.

Declaration

static String formatSample(final int aValue, final long aTimestamp) 

Method Source Code

//package com.java2s;
/*//w  w w .j  a  v a2 s.  c  o  m
 * OpenBench LogicSniffer / SUMP project
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 *
 * Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
 * Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
 */

public class Main {
    /**
     * Formats the given value and timestamp into a single sample string.
     * 
     * @param aValue
     *          the sample value to format;
     * @param aTimestamp
     *          the timestamp to format.
     * @return the sample string, in the form of
     *         &lt;value<sub>16</sub>&gt;@&lt;timestamp<sub>10</sub>&gt;.
     */
    static String formatSample(final int aValue, final long aTimestamp) {
        final String hexVal = Integer.toHexString(aValue
                & Integer.MAX_VALUE);
        final StringBuilder sb = new StringBuilder();
        sb.append("00000000".substring(hexVal.length()));
        sb.append(hexVal);
        sb.append("@");
        sb.append(Long.toString(aTimestamp & Long.MAX_VALUE));
        return sb.toString();
    }
}

Related

  1. formatNanosec(long timeNanosec)
  2. formatPeroid(long time)
  3. formatRemainingTime(float seccounds)
  4. formatRuntime(long runtime)
  5. formatRuntime(long time, boolean fixedlength)
  6. formatSignificantElapsedTime(final long seconds)
  7. formatStartRowKeyString(String id, String timestampStart)
  8. formatStrDateTime(String stringDateTime)
  9. formatString(String agentId, long agentStartTime, long transactionSequence)