大家好,又见面了,我是你们的朋友全栈君。
获取当前时间。 datetime = COleDateTime::GetCurrentTime(); CTime和COleDateTime具有几乎同样的功能。 与CTime相比, COleDateTime的优点在于它支持DWORD变量。 COleDateTime使用的位数是双浮点的两倍,既然CTime只是简单地计算从1970年1月1日之后经过的秒数,所以到了2 0 3 7年它将达到4 2 9 4 9 6 7 2 9 5,从而不能再使用。 //CString—>COleDateTime COleVariant vtime(strCString);COleDateTime time4=vtime; //CTime—>time_t COleDateTime time3(time2); //time_t—>COleDateTime.
//CString COleDateTime CTime互相转换 //CString—>COleDateTime strCString=”2003-10-27 6:24:37″; COleVariant vtime(strCString); vtime.ChangeType(VT_DATE); COleDateTime time4=vtime;
//COleDataTime—>CTime COleDateTime time1(1977,4,16,2,2,2); SYSTEMTIME systime; VariantTimeToSystemTime(time1, &systime); CTime tm(systime);
//CTime–>COleDateTime time_t time2=tm.GetTime(); //CTime—>time_t COleDateTime time3(time2); //time_t—>COleDateTime
CString str = tDate.Format(_T(“%Y-%m-%d”));
//COleDataTime—>CTime COleDateTime time1(1977,4,16,2,2,2); SYSTEMTIME systime; VariantTimeToSystemTime(time1, &systime); CTime tm(systime);
参考附录 { CString strCString=”ABC”; char strchar[256],*pstr; pstr=(LPSTR)(LPCTSTR)strCString; //CString—->char* strcpy(strchar,(LPSTR)(LPCTSTR)strCString); //CString—->char[] _bstr_t strbstr=pstr; //char*—->_bstr_t WCHAR *strWCHAR=strbstr; //b_str_t—>UNICODE strbstr=strWCHAR; pstr=strbstr; //UNICODE—->char* strCString=”10″; int istr=atoi((LPSTR)(LPCTSTR)strCString); //CString、char[]、char*——>int strCString.Format(“%d”,istr); //int—–>CString sprintf(strchar,”%d”,istr); //int—–>char[] pstr=new char[256]; //字符串申请空间 strcpy(pstr,”ABC”); //字符串赋值 delete []pstr; //字符串释放 string strstring=”ABC”; pstr=(char*)strstring.c_str(); //string—->char* strCString=”2003-10-27 6:24:37″; //CString—>COleDateTime COleVariant vtime(strCString); vtime.ChangeType(VT_DATE); COleDateTime time4=vtime; COleDateTime time1(1977,4,16,2,2,2); //COleDataTime—>CTime SYSTEMTIME systime; VariantTimeToSystemTime(time1, &systime); CTime tm(systime); time_t time2=tm.GetTime(); //CTime—>time_t COleDateTime time3(time2); //time_t—>COleDateTime //判断字符串是否是某种类型 CString sValue(“123.1”); COleVariant vValue(sValue); BOOL bStrIsFloat = (SUCCEEDED(VariantChangeType(&vValue, &vValue, 0, VT_R8)) && sValue.Find(‘.’) != -1); if(bStrIsFloat) { AfxMessageBox(“浮点”); } }
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/161056.html原文链接:https://javaforall.cn