添加项目文件。
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JY.Utility
|
||||
{
|
||||
public class ConvertHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// DateTime转long
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public static long DateTimeToLong(DateTime dt)
|
||||
{
|
||||
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
||||
TimeSpan toNow = dt.Subtract(dtStart);
|
||||
long timeStamp = toNow.Ticks;
|
||||
timeStamp = long.Parse(timeStamp.ToString().Substring(0, timeStamp.ToString().Length - 4));
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字符串转数字
|
||||
/// </summary>
|
||||
/// <param name="strData"></param>
|
||||
/// <returns></returns>
|
||||
public static Decimal StringToDecimal(string strData)
|
||||
{
|
||||
Decimal dData = 0.0M;
|
||||
try
|
||||
{
|
||||
if (strData.ToUpper().Contains("E"))
|
||||
{
|
||||
dData = Convert.ToDecimal(Decimal.Parse(strData.ToString(), System.Globalization.NumberStyles.Float).ToString("f4"));
|
||||
}
|
||||
else
|
||||
{
|
||||
dData = Convert.ToDecimal(Decimal.Parse(strData).ToString("f4"));
|
||||
}
|
||||
if (dData > 10000000000)
|
||||
{
|
||||
return 0.00M;
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return dData;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user