Convert integer to hexadecimal and back again

// Store integer 182 int intValue = 182; // Convert integer 182 as a hex in a string variable string hexValue = intValue.ToString(“X”); // Convert the hex string back to the number int intAgain = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber); from http://www.geekpedia.com/KB8_How-do-I-convert-from-decimal-to-hex-and-hex-to-decimal.html HINT (from the comments): Use .ToString(“X4”) to get exactly 4 digits with leading 0, or .ToString(“x4”) … Read more

How do I convert from int to String?

Normal ways would be Integer.toString(i) or String.valueOf(i). The concatenation will work, but it is unconventional and could be a bad smell as it suggests the author doesn’t know about the two methods above (what else might they not know?). Java has special support for the + operator when used with strings (see the documentation) which … Read more

Converting a String to DateTime

Since you are handling 24-hour based time and you have a comma separating the seconds fraction, I recommend that you specify a custom format: DateTime myDate = DateTime.ParseExact(“2009-05-08 14:40:52,531”, “yyyy-MM-dd HH:mm:ss,fff”, System.Globalization.CultureInfo.InvariantCulture);