在comm c ++中将DATE转换为String [英] Convert DATE to String in comm c++

查看:159
本文介绍了在comm c ++中将DATE转换为String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了整整一夜才找到将C ++的DATE数据类型转换为COMM中的字符串的单个示例。我的界面函数返回以下值,我想以人类可更新的格式显示值。比如,

I spend whole night to find out single example to convert DATE datatype of c++ to string in COMM. My interface function returns following values and i want show that values in human redable format. Like,

DATE JobStartTime;
CurrentJob->get_StartTime(&JobStartTime);



它返回如16324.5455等的价格。



当我去DATE定义时,它会向我显示类似的内容,


And it return valules like, 16324.5455 etc.

When i go to defination of DATE it show me something like,

typedef double DATE;



这再次让我感到困惑。作为DATE它再次加倍,所以我将如何转换它变成了类似的东西,



02/05/2013 11.41.25



等请帮助我我是comm的新手。


Which is again confuse me.As a DATE it is again double,so how would i convert it into something like,

02/05/2013 11.41.25

etc. Please help me i am very new in comm.

推荐答案

你标记了MFC。所以你可以在内部使用 COleDateTime 类,它使用 DATE 并提供格式() [ ^ ]将其转换为字符串的功能:

You tagged MFC. So you can use the COleDateTime class which uses DATE internally and provides the Format()[^] function to convert it to a string:
COleDateTime dt(JobStartTime);
CString strJobStartTime = dt.Format(_T("%d/%m/%Y %H.%M.%S"));



以上格式化字符串就像你问题中的例子一样。



[更新]

当不使用MFC时,您可以在内部使用COleDateTime使用的功能: VarBstrFromDate [ ^ ]。


这篇关于在comm c ++中将DATE转换为String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆