![]() |
Home · All Classes · All Functions · Overviews |
The DateTimeFormatter allows you to control the format of a date string. More...
|
|
DateTimeFormatter { id: formatter; date: System.date } Text { text: formatter.dateText }
By default, the text properties (dateText, timeText, and dateTimeText) will return the date and time using the current system locale's format.
The source date and time to be used by the formatter.
// setting the date and time DateTimeFormatter { date: System.date; time: System.time }
For convienience it is possible to set the datetime property to set both the date and the time.
// setting the datetime DateTimeFormatter { dateTime: System.dateTime }
There can only be one instance of date and time per formatter; if date, time, and dateTime are all set the actual date and time used is not guaranteed.
Note: If no date is set, dateTimeText will be just the date; If no time is set, the dateTimeText will be just the time.
Specifies a custom format which the DateTime Formatter can use.
If there is no explictly specified format the DateTimeFormatter will use the system locale's default 'short' setting.
The text's format may be modified by setting:
If only the format for date is defined, the time and dateTime formats will be defined as the system locale default and likewise for the others.
Syntax for the format is based on the QDateTime::toString() formatting options.
// Format the date such that the dateText is: '1997-12-12' DateTimeFormatter { id: formatter; dateTime: Today.dateTime; formatDate: "yyyy-MM-d" }
Assigning an empty string to a particular format will reset it.
Formatted text representations of the date, time, and date and time, respectively.
If there is no explictly specified format the DateTimeFormatter will use the system locale's default 'short' setting.
// specify source date (assuming today is February 19, 2009)
DateTimeFormatter { id: formatter; dateTime: Today.date }
// display the full date and time
Text { text: formatter.dateText }
Would be equivalent to the following for a US English locale:
// display the date Text { text: "2/19/09" }
longStyle : bool |
This property causes the formatter to use the system locale's long format rather than short format by default.
This setting is off by default.
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt 4.7.0 |