/** * Converts a double to a string with no padding. * * @param d the double to convert * @return the formatted String representing the double. * @see #convert(double, int) */ public static String convert(double d) { return convert(d, 0); }
private static void checkString(String value) throws FieldConvertError { assertLength(value, DATE_LENGTH, TYPE); assertDigitSequence(value, 0, DATE_LENGTH, TYPE); }
protected static void assertLength(String value, int i, String type) throws FieldConvertError { if (value.length() != i) { throwFieldConvertError(value, type); } }
public String getStartTime() { try { return UtcTimestampConverter.convert(session.getStartTime(), true); } catch (IOException e) { return "[ERROR]"; } }
/** * Converts a double to a string with padding. * * @param d the double to convert * @param padding the number of zeros to add to end of the formatted double * @return the formatted String representing the double. */ public static String convert(double d, int padding) { return getDecimalFormat(padding).format(d); }
/** * Convert a time (represented as a Date) to a String (HH:MM:SS or HH:MM:SS.SSS) * * @param d the date with the time to convert * @param includeMilliseconds controls whether milliseconds are included in the result * @return a String representing the time. */ public static String convert(Date d, boolean includeMilliseconds) { return getFormatter(includeMilliseconds).format(d); }
private static DateFormat getFormatter() { UtcDateOnlyConverter converter = UTC_DATE_CONVERTER.get(); if (converter == null) { converter = new UtcDateOnlyConverter(); UTC_DATE_CONVERTER.set(converter); } return converter.dateFormat; }
private static DateFormat getFormatter(boolean includeMillis) { UtcTimeOnlyConverter converter = UTC_TIME_CONVERTER.get(); if (converter == null) { converter = new UtcTimeOnlyConverter(); UTC_TIME_CONVERTER.set(converter); } return includeMillis ? converter.utcTimeFormatMillis : converter.utcTimeFormat; }
private BigDecimal getDecimalFromString(int field, String s) { try { return DecimalConverter.convert(s); } catch (final FieldConvertError e) { throw newIncorrectDataException(e, field); } }
public char getChar(int field) throws FieldNotFound { try { return CharConverter.convert(getString(field)); } catch (final FieldConvertError e) { throw newIncorrectDataException(e, field); } }
public int getInt(int field) throws FieldNotFound { try { return IntConverter.convert(getString(field)); } catch (final FieldConvertError e) { throw newIncorrectDataException(e, field); } }
public LocalDateTime getUtcTimeStamp(int field) throws FieldNotFound { try { return UtcTimestampConverter.convertToLocalDateTime(getString(field)); } catch (final FieldConvertError e) { throw newIncorrectDataException(e, field); } }
public LocalTime getUtcTimeOnly(int field) throws FieldNotFound { try { return UtcTimeOnlyConverter.convertToLocalTime(getString(field)); } catch (final FieldConvertError e) { throw newIncorrectDataException(e, field); } }
public LocalDate getUtcDateOnly(int field) throws FieldNotFound { try { return UtcDateOnlyConverter.convertToLocalDate(getString(field)); } catch (final FieldConvertError e) { throw newIncorrectDataException(e, field); } }
private static void checkString(String value) throws FieldConvertError { assertLength(value, DATE_LENGTH, TYPE); assertDigitSequence(value, 0, DATE_LENGTH, TYPE); }
/** * Converts a double to a string with no padding. * * @param d the double to convert * @return the formatted String representing the double. * @see #convert(double, int) */ public static String convert(double d) { return convert(d, 0); }
protected static void assertLength(String value, String type, int... lengths) throws FieldConvertError { for (int length : lengths) { if (value.length() == length) { return; } } throwFieldConvertError(value, type); }
/** * Converts a double to a string with no padding. * * @param d the double to convert * @return the formatted String representing the double. * @see #convert(double, int) */ public static String convert(double d) { return convert(d, 0); }
public double getDouble(int field) throws FieldNotFound { try { return DoubleConverter.convert(getString(field)); } catch (final FieldConvertError e) { throw newIncorrectDataException(e, field); } }