我用楼上的建议,写了如下的示例代码:
@
#include <QtCore/QCoreApplication>
#include <QtCore/QLocale>
#include <QtCore/QDateTime>
#include <QtCore/QTextStream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QLocale chineseLocale(QLocale::Chinese);
QDateTime currentDateTime = QDateTime::currentDateTime();
QString TimeString = chineseLocale.toString(currentDateTime, QString("AP hh:mm:ss"));
QString TimeLongFormatString = chineseLocale.toString(currentDateTime, QLocale::LongFormat);
QString TimeShortFormatString = chineseLocale.toString(currentDateTime, QLocale::ShortFormat);
QString TimeNarrowFormatString = chineseLocale.toString(currentDateTime, QLocale::NarrowFormat);
QTextStream cout(stdout, QIODevice::WriteOnly);
cout<<TimeString<<endl;
cout<<TimeLongFormatString<<endl;
cout<<TimeShortFormatString<<endl;
cout<<TimeNarrowFormatString<<endl;
cout<<chineseLocale.amText()<<endl;
cout<<chineseLocale.pmText()<<endl;
return a.exec();
}
@
输出结果为
PM 06:40:38
2012年8月24日星期五 中国标准时间PM6时40分38秒
12-8-24 PM6:40
12-8-24 PM6:40
上午
下午
诚如楼上所言,前四行中的PM(AM)翻译为下午(上午)更为合适些!
[quote author="wwycheuk" date="1332551640"]如無人反對我就會將繁體中文版 AM 和 PM 翻譯為「上午」和「下午」[/quote]