Package io.github.zazalng.utility
Class DBFUtils
java.lang.Object
io.github.zazalng.utility.DBFUtils
Utility class containing static methods for decoding specific DBF field data types.
These methods handle conversions from raw byte arrays or padded strings into
appropriate Java types such as LocalDate, BigDecimal, and LocalDateTime.
- Since:
- 1.0.0
- Author:
- Zazalng
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic LocalDateParses a DBF Date string (format YYYYMMDD) into aLocalDate.static LocalDateTimeparseDateTime(byte[] data) Decodes 8 raw bytes representing a VFP or dBase Level 7 DateTime/Timestamp into aLocalDateTime.static BigDecimalparseDoubleBinary(byte[] data) Decodes 8 raw bytes representing a VFP Double/Currency type (IEEE 754 64-bit float) into aBigDecimal.static IntegerparseIntBinary(byte[] data) Decodes 4 raw bytes representing a VFP Integer type into anInteger.static BigDecimalparseNumeric(String text) Parses a DBF Numeric or Float string into aBigDecimal.
-
Method Details
-
parseDate
Parses a DBF Date string (format YYYYMMDD) into aLocalDate.- Parameters:
text- The 8-character string representing the date.- Returns:
- The parsed
LocalDate, ornullif the string is invalid or empty.
-
parseNumeric
Parses a DBF Numeric or Float string into aBigDecimal.- Parameters:
text- The string containing the numeric value, possibly padded with spaces.- Returns:
- The parsed
BigDecimal, ornullif the string cannot be parsed.
-
parseDoubleBinary
Decodes 8 raw bytes representing a VFP Double/Currency type (IEEE 754 64-bit float) into aBigDecimal.- Parameters:
data- The 8-byte array containing the little-endian binary double.- Returns:
- The decoded value as a
BigDecimal, ornullif data is insufficient.
-
parseIntBinary
Decodes 4 raw bytes representing a VFP Integer type into anInteger.- Parameters:
data- The 4-byte array containing the little-endian binary integer.- Returns:
- The decoded
Integer, ornullif data is insufficient.
-
parseDateTime
Decodes 8 raw bytes representing a VFP or dBase Level 7 DateTime/Timestamp into aLocalDateTime.The first 4 bytes are the Julian day number (since 1/1/4713 BC). The second 4 bytes are milliseconds since midnight.
- Parameters:
data- The 8-byte array containing the little-endian Julian day and milliseconds.- Returns:
- The decoded
LocalDateTime, ornullif data is insufficient or decoding fails.
-