CustomDateFormatter

Since: BlackBerry 10.0.0

#include <bb/utility/i18n/CustomDateFormatter>

To link against this class, add the following line to your .pro file: LIBS += -lbbutilityi18n

Formats QDateTime objects using skeleton patterns.

A date/time format skeleton is a QString containing any arrangement of icu::SimpleDateFormat pattern characters specified by the Internationalization Components for Unicode (ICU). The table below also shows the Qt4 equivalencies for your convenience. The passed in QString should only contain character sequences from the left column (ICU).

Do not include any whitespace or punctuation. The formatter will automatically format using the most appropriate date-time pattern for the current system settings.

Supported characters:

An asterisk (*) in the left column indicates that this character may be repeated to pad the output with 0s.

ICU

description

Qt4

US English example

notes

G

era designator

AD

AD

GGGG

era designator

Anno Domini

y

year

yyyy

1996

Can also use yyyy

yy

2-digit year

yy

96

00 through 99

Y

of year

1997

3rd month of year 1997 <-> March 1996

YY

of 2-digit year

97

00 through 99

u

extended year

4601

Based on region locale calendar

U

cyclic year name

ren-chen

Falls back to number (29) for many locales

Q

quarter

2

Use QQ to pad with 0s

QQQ

quarter

Q2

QQQQ

quarter

2nd quarter

qqq

standalone quarter

Q2

qqqq

quarter

2nd quarter

M

month in year

M

8

MM

month in year

MM

08

MMM

month in year

MMM

Aug

MMMM

month in year

MMMM

August

LLL

standalone month

Aug

LLLL

standalone month

August

* w

week in year

33

* W

week in month

3

* F

weekday in month

3

i.e. 3rd Tuesday in August

* g

Julian day

2451370

* D

day in year

226

* d

day in month

d

9

e

day of week

2

Numeric: 1 through 7

ee

day of week

02

Numeric: 01 through 07

E

day of week

ddd

Tue

eeee

day of week

Tues

EEEE

day of week

dddd

Tuesday

ccc

standalone day

Tue

cccc

standalone day

Tuesday

* H

hour in day

h

0

0 through 23

* k

hour of day

24

1 through 24; i.e. the 1st hour of the day

a

am/pm marker

AP

PM

Qt4 uses AP for AM/PM and ap for am/am

* h

hour of am/pm

h

12

1 through 12; Qt4 checks for presence of AP/ap

* K

hour in am/pm

0

0 through 11

* m

minute in hour

m

30

* s

second in minute

s

55

S

decisecond

9

Tenths of the next second: 0 through 9

SS

centisecond

97

Hundredths of the next second: 00 through 99

SSS

millisecond

zzz

978

Thousandths of the next second: 000 through 999

* A

ms in day

69540000

z

timezone

PST

zzzz

timezone

Pacific Standard Time

Z

timezone

-0800

RFC 822

ZZZZ

timezone

t

GMT-08:00

ZZZZZ

timezone

-08:00

ISO 8601

v

timezone

PT

Short wall (generic) time

vvvv

timezone

Pacific Time

Long wall (generic) time

V

timezone

PST

VVVV

timezone

United States Time (Los Angeles)

Location

Sample skeleton patterns:

skeleton

US English

Catalan

Liechtenstein

MMMMEEEEd

Tuesday, October 30

dimarts 30 d'octubre

Dienstag, 30. Oktober

MMMMEd

Tue, October 30

dt. 30 d'octubre

Di., 30. Oktober

MMMEd

Tue, Oct 30

dt. 30 d'oct.

Di., 30. Okt

yMMMM

October 2012

octubre de 2012

Oktober 2012

MMMd

Oct 30

30 d'oct.

30. Okt

Ehm

Tue 7:46 PM

dt. 19.46

Di. 19:46


Overview

Properties Index

Public Functions Index

CustomDateFormatter (const QString &skeleton=QString(), QObject *parent=0)
virtual ~CustomDateFormatter ()
Q_INVOKABLE QStringformat (const QDateTime &dateTime) const
Q_INVOKABLE boolisValid () const
Q_SLOT voidsetSkeleton (const QString &skeleton)
QStringskeleton () const

Properties

QString skeleton

A collection of letter sequences used for parsing and formatting dates.

Since:

BlackBerry 10.0.0

Public Functions

CustomDateFormatter (

Creates a date/time formatter of the supplied skeleton type.

Parameters
skeleton

The skeleton this object should format with.

parent

If not 0, the supplied parent will be responsible for deleting this instance.

Since:

BlackBerry 10.0.0

virtual~CustomDateFormatter ()

Destructor.

Since:

BlackBerry 10.0.0

Q_INVOKABLE QString format (

Prints out date and time components formatted and localized according to the system settings.

Parameters
dateTime

A QDateTime object that should be printed using this format.

Return:

A QString with a localized and formatted date and time.

Since:

BlackBerry 10.0.0

Q_INVOKABLE bool isValid ()

Verifies if this formatter was created successfully.

Return:

true if this DateFormatter is ready to use, false otherwise.

Since:

BlackBerry 10.0.0

Q_SLOT void setSkeleton (

Changes the skeleton used for parsing and formatting dates.

Parameters
skeleton

A QString to use as the new skeleton.

Since:

BlackBerry 10.0.0

QString skeleton ()

Returns the skeleton used for parsing and formatting dates/time.

Return:

The skeleton used for parsing and formatting dates/time.

Since:

BlackBerry 10.0.0

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus