private long calculateRemainderAndPutMinus(final int offset, final long value) { if (value < 0) { putChar(offset, '-'); return value; } else { // Deal with negatives to avoid overflow for Integer.MAX_VALUE return -1L * value; } }
private void setPossDupFlag( final int possDupSrcOffset, final int messageOffset, final int claimOffset, final MutableDirectBuffer claimBuffer) { final int possDupClaimOffset = srcToClaim(possDupSrcOffset, messageOffset, claimOffset); mutableAsciiFlyweight.wrap(claimBuffer); mutableAsciiFlyweight.putChar(possDupClaimOffset, 'Y'); }
static void encodeFraction( final long epochSecond, final int fractionOfSecond, final MutableAsciiBuffer string, final int offset, final int fractionFieldLength) { int secondOfDay = (int)Math.floorMod(epochSecond, SECONDS_IN_DAY); final int hours = secondOfDay / SECONDS_IN_HOUR; secondOfDay -= hours * SECONDS_IN_HOUR; final int minutes = secondOfDay / SECONDS_IN_MINUTE; secondOfDay -= minutes * SECONDS_IN_MINUTE; string.putNaturalPaddedIntAscii(offset, 2, hours); string.putChar(offset + 2, ':'); string.putNaturalPaddedIntAscii(offset + 3, 2, minutes); string.putChar(offset + 5, ':'); string.putNaturalPaddedIntAscii(offset + 6, 2, secondOfDay); if (fractionOfSecond > 0) { string.putChar(offset + 8, '.'); string.putNaturalPaddedIntAscii(offset + 9, fractionFieldLength, fractionOfSecond); } } }
private static int encodeFraction( final long epochFraction, final MutableAsciiBuffer string, final int offset, final long minEpochFraction, final long maxEpochFraction, final long fractionInSecond, final int lengthWithFraction, final int fractionFieldLength) { validate(epochFraction, minEpochFraction, maxEpochFraction); final long localSecond = localSecond(epochFraction, fractionInSecond); final long epochDay = epochDay(localSecond); final int fractionOfSecond = fractionOfSecond(epochFraction, fractionInSecond); encodeDate(epochDay, string, offset); string.putChar(offset + LENGTH_OF_DATE, '-'); UtcTimeOnlyEncoder.encodeFraction( localSecond, fractionOfSecond, string, offset + LENGTH_OF_DATE_AND_DASH, fractionFieldLength); return fractionOfSecond > 0 ? lengthWithFraction : LENGTH_WITHOUT_MILLISECONDS; }
flyweight.putChar(LENGTH_OF_DATE, '-'); UtcTimeOnlyEncoder.encodeFraction( localSecond, fractionOfSecond, flyweight, LENGTH_OF_DATE_AND_DASH, fractionFieldLength);
public int encode(final MutableAsciiBuffer buffer, final int offset) { final int endYear = offset + SIZE_OF_YEAR; final int endMonth = endYear + SIZE_OF_MONTH; buffer.putNaturalPaddedIntAscii(offset, SIZE_OF_YEAR, year()); buffer.putNaturalPaddedIntAscii(endYear, SIZE_OF_MONTH, month().getValue()); final int dayOfMonth = dayOfMonth(); if (dayOfMonth != NONE) { buffer.putNaturalPaddedIntAscii(endMonth, SIZE_OF_DAY_OF_MONTH, dayOfMonth); return LONG_LENGTH; } else { final int weekOfMonth = weekOfMonth(); if (weekOfMonth != NONE) { buffer.putChar(endMonth, 'w'); buffer.putNaturalPaddedIntAscii(endMonth + 1, SIZE_OF_WEEK_OF_MONTH, weekOfMonth); return LONG_LENGTH; } } return SHORT_LENGTH; }