| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Core.Mes.Client.Common.Util
- {
- public class LgConvertUtil
- {
- /// <summary>
- /// 返回double 类型
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public static double ConvetToDouble(Object obj)
- {
- double result = 0;
- try
- {
- result = Convert.ToDouble(obj);
- }
- catch
- {
- result = 0;
- }
- return result;
- }
- public static int ConvetToInt32(Object obj)
- {
- Int32 result = 0;
- try
- {
- result = Convert.ToInt32(obj);
- }
- catch
- {
- result = 0;
- }
- return result;
- }
- /// <summary>
- /// 返回时间类型,obj为空有异常,则默认返回200年前
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public static DateTime ConvertToDateTime(Object obj)
- {
- DateTime dt = DateTime.Now.AddYears(-200);
- try
- {
- dt = Convert.ToDateTime(obj);
- }
- catch
- {
- }
- return dt;
- }
- public static string ConvetToString(Object obj)
- {
- string str = "";
- try
- {
- str = Convert.ToString(obj);
- }
- catch
- {
- }
- return str;
- }
- }
- }
|