UTC格式转换成北京时间格式:
/// <summary>
/// UTC格式与datatime的转换
/// </summary>
/// <param name="utc"></param>
/// <returns></returns>
public DateTime ConvertIntDatetime(double utc)
{
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(, , )); startTime = startTime.AddSeconds(utc); startTime = startTime.AddHours();//转化为北京时间(北京时间=UTC时间+8小时 )
return startTime;
}
十六进制换算为十进制:
/// <summary>
/// 十六进制换算为十进制
/// </summary>
/// <param name="strColorValue"></param>
/// <returns></returns>
public int GetHexadecimalValue(String strColorValue)
{
char[] nums = strColorValue.ToCharArray(); int total = ; try
{
for (int i = ; i < nums.Length; i++)
{
String strNum = nums[i].ToString().ToUpper(); switch (strNum)
{
case "A":
strNum = "";
break; case "B":
strNum = "";
break; case "C":
strNum = "";
break; case "D":
strNum = "";
break; case "E":
strNum = "";
break; case "F":
strNum = "";
break; default:
break;
}
double power = Math.Pow(, Convert.ToDouble(nums.Length - i - )); total += Convert.ToInt32(strNum) * Convert.ToInt32(power);
} }
catch (System.Exception ex)
{
String strErorr = ex.ToString(); return ;
} return total;
}