Skip to content

Commit 1e8675f

Browse files
committed
change utils
1 parent 4039c1a commit 1e8675f

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/Apache.IoTDB/Utils.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static DateTime ParseIntToDate(int dateInt)
101101
{
102102
throw new ArgumentException("Date must be between 10000101 and 99991231.");
103103
}
104-
return new DateTime(dateInt / 10000, dateInt / 100 % 100, dateInt % 100);
104+
return DateTime.TryParseExact(dateInt.ToString(), "yyyyMMdd", null, System.Globalization.DateTimeStyles.None, out DateTime date) ? date : throw new ArgumentException("Date must be between 10000101 and 99991231.");
105105
}
106106

107107
public static int ParseDateToInt(DateTime? dateTime)
@@ -119,13 +119,7 @@ public static int ParseDateToInt(DateTime? dateTime)
119119

120120
public static string ByteArrayToHexString(byte[] bytes)
121121
{
122-
StringBuilder hex = new StringBuilder(bytes.Length * 2);
123-
hex.Append("0x");
124-
foreach (byte b in bytes)
125-
{
126-
hex.AppendFormat("{0:x2}", b);
127-
}
128-
return hex.ToString();
122+
return "0x" + BitConverter.ToString(bytes).Replace("-", "").ToLowerInvariant();
129123
}
130124
}
131125
}

0 commit comments

Comments
 (0)