|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QLocale
public class QLocale
The QLocale
class converts between numbers and their string representations in various languages. QLocale
is initialized with a language/country pair in its constructor and offers number-to-string and string-to-number conversion functions similar to those in QString.
Example:
QLocale egyptian = new QLocale(QLocale.Language.Arabic, QLocale.Country.Egypt); String s1 = egyptian.toString(1.571429E+07, (byte) 'e'); String s2 = egyptian.toString(10); double d = egyptian.toDouble(s1); int i = egyptian.toInt(s2);
QLocale
supports the concept of a default locale, which is determined from the system's locale settings at application startup. The default locale can be changed by calling the static member setDefault()
. Setting the default locale has the following effects: QLocale
object is constructed with the default constructor, it will use the default locale's settings.QLocale
directly: QLocale.setDefault(new QLocale(QLocale.Language.Hebrew, QLocale.Country.Israel)); QLocale hebrew = new QLocale(); // Constructs a default QLocale String s1 = hebrew.toString(15714.3, (byte) 'e'); double d; d = hebrew.toDouble("1234,56"); // d == 0.0 d = hebrew.toDouble("1234.56"); // d == 1234.56When a language/country pair is specified in the constructor, one of three things can happen:
QLocale
defaults to the default locale (see setDefault()
).English
/UnitedStates
. Use language()
and country()
to determine the actual language and country values used.
An alternative method for constructing a QLocale
object is by specifying the locale name.
QLocale korean = new QLocale("ko"); QLocale swiss = new QLocale("de_CH");This constructor converts the locale name to a language/country pair; it does not use the system locale database.
The double-to-string and string-to-double conversion functions are covered by the following licenses:Copyright (c) 1991 by AT&T.Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software.THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.This product includes software developed by the University of California, Berkeley and its contributors.QLocale's data is based on Common Locale Data Repository v1.4.
Nested Class Summary | |
---|---|
static class |
QLocale.Country
This enumerated type is used to specify a country. |
static class |
QLocale.FormatType
|
static class |
QLocale.Language
This enumerated type is used to specify a language. |
static class |
QLocale.MeasurementSystem
This enum defines which units are used for measurement. |
static class |
QLocale.NumberOption
This enum defines a set of options for number-to-string and string-to-number conversions. |
static class |
QLocale.NumberOptions
This is a flags class for com.trolltech.qt.core.QLocale.NumberOption |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Constructor Summary | |
---|---|
QLocale()
Constructs a QLocale object initialized with the default locale. |
|
QLocale(QLocale.Language language)
Constructs a QLocale object with the specified language and country. |
|
QLocale(QLocale.Language language,
QLocale.Country country)
Constructs a QLocale object with the specified language and country. |
|
QLocale(QLocale other)
Constructs a QLocale object as a copy of other. |
|
QLocale(java.lang.String name)
Constructs a QLocale object with the specified name, which has the format "language[_country][.codeset][@modifier]" or "C", where: language is a lowercase, two-letter, ISO 639 language code, territory is an uppercase, two-letter, ISO 3166 country code, and codeset and modifier are ignored. If the string violates the locale format, or language is not a valid ISO 369 code, the "C" locale is used instead. |
Method Summary | |
---|---|
static QLocale |
c()
Returns a QLocale object initialized to the "C" locale. |
QLocale |
clone()
This method is reimplemented for internal reasons |
static java.util.List |
countriesForLanguage(QLocale.Language lang)
Returns the list of countries that have entires for language in Qt's locale database. |
QLocale.Country |
country()
Returns the country of this locale. |
static java.lang.String |
countryToString(QLocale.Country country)
Returns a QString containing the name of country. |
java.lang.String |
dateFormat()
Returns the date format used for the current locale. |
java.lang.String |
dateFormat(QLocale.FormatType format)
Returns the date format used for the current locale. |
java.lang.String |
dateTimeFormat()
Returns the date time format used for the current locale. |
java.lang.String |
dateTimeFormat(QLocale.FormatType format)
Returns the date time format used for the current locale. |
java.lang.String |
dayName(int arg__1)
Returns the localized name of day, in the format specified by type. |
java.lang.String |
dayName(int arg__1,
QLocale.FormatType format)
Returns the localized name of day, in the format specified by type. |
char |
decimalPoint()
Returns the decimal point character of this locale. |
char |
exponential()
Returns the exponential character of this locale. |
static QLocale |
fromNativePointer(QNativePointer nativePointer)
|
char |
groupSeparator()
Returns the group separator character of this locale. |
QLocale.Language |
language()
Returns the language of this locale. |
static java.lang.String |
languageToString(QLocale.Language language)
Returns a QString containing the name of language. |
QLocale.MeasurementSystem |
measurementSystem()
Returns the measurement system for the locale. |
java.lang.String |
monthName(int arg__1)
Returns the localized name of month, in the format specified by type. |
java.lang.String |
monthName(int arg__1,
QLocale.FormatType format)
Returns the localized name of month, in the format specified by type. |
java.lang.String |
name()
Returns the language and country of this locale as a string of the form " language_country ", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two-letter ISO 3166 country code. |
static QNativePointer |
nativePointerArray(QLocale[] array)
|
char |
negativeSign()
Returns the negative sign character of this locale. |
QLocale.NumberOptions |
numberOptions()
Returns the options related to number conversions for this QLocale instance. |
char |
percent()
Returns the percent character of this locale. |
void |
readFrom(QDataStream arg__1)
|
static void |
setDefault(QLocale locale)
Sets the global default locale to locale. |
void |
setNumberOptions(QLocale.NumberOption[] options)
Sets the options related to number conversions for this QLocale instance. |
void |
setNumberOptions(QLocale.NumberOptions options)
Sets the options related to number conversions for this QLocale instance. |
static QLocale |
system()
Returns a QLocale object initialized to the system locale. |
java.lang.String |
timeFormat()
Returns the time format used for the current locale. |
java.lang.String |
timeFormat(QLocale.FormatType format)
Returns the time format used for the current locale. |
char |
toChar(java.lang.String s)
Returns the char, which must be written as a number between 0 and 255, represented by the localized string s. |
char |
toChar(java.lang.String s,
int base)
Returns the char, which must be written as a number between 0 and 255, represented by the localized string s, using base base. |
QDate |
toDate(java.lang.String string)
Parses the date string given in string and returns the date. |
QDate |
toDate(java.lang.String string,
QLocale.FormatType arg__2)
Parses the date string given in string and returns the date. |
QDate |
toDate(java.lang.String string,
java.lang.String format)
Parses the date string given in string and returns the date. |
QDateTime |
toDateTime(java.lang.String string)
Parses the date/time string given in string and returns the time. |
QDateTime |
toDateTime(java.lang.String string,
QLocale.FormatType format)
Parses the date/time string given in string and returns the time. |
QDateTime |
toDateTime(java.lang.String string,
java.lang.String format)
Parses the date/time string given in string and returns the time. |
double |
toDouble(java.lang.String s)
Returns the double represented by the localized string s, or 0.0 if the conversion failed. |
float |
toFloat(java.lang.String s)
Returns the float represented by the localized string s, or 0.0 if the conversion failed. |
int |
toInt(java.lang.String s)
Returns the int represented by the localized string s, using base 10. |
int |
toInt(java.lang.String s,
int base)
Returns the int represented by the localized string s, using base base. |
long |
toLong(java.lang.String s)
Returns the long represented by the localized string s, using base 10. |
long |
toLong(java.lang.String s,
int base)
Returns the long represented by the localized string s, using base base. |
short |
toShort(java.lang.String s)
Returns the short represented by the localized string s. |
short |
toShort(java.lang.String s,
int base)
Returns the short represented by the localized string s, using base base. |
java.lang.String |
toString(char i)
|
java.lang.String |
toString(double i)
|
java.lang.String |
toString(double i,
byte f)
|
java.lang.String |
toString(double i,
byte f,
int prec)
|
java.lang.String |
toString(float i)
|
java.lang.String |
toString(float i,
byte f)
|
java.lang.String |
toString(float i,
byte f,
int prec)
|
java.lang.String |
toString(int i)
|
java.lang.String |
toString(long i)
|
java.lang.String |
toString(QDate date)
|
java.lang.String |
toString(QDate date,
QLocale.FormatType format)
|
java.lang.String |
toString(QDate date,
java.lang.String formatStr)
|
java.lang.String |
toString(QDateTime dateTime)
|
java.lang.String |
toString(QDateTime dateTime,
QLocale.FormatType format)
|
java.lang.String |
toString(QDateTime dateTime,
java.lang.String format)
|
java.lang.String |
toString(QTime time)
|
java.lang.String |
toString(QTime time,
QLocale.FormatType format)
|
java.lang.String |
toString(QTime time,
java.lang.String formatStr)
|
QTime |
toTime(java.lang.String string)
Parses the time string given in string and returns the time. |
QTime |
toTime(java.lang.String string,
QLocale.FormatType arg__2)
Parses the time string given in string and returns the time. |
QTime |
toTime(java.lang.String string,
java.lang.String format)
Parses the time string given in string and returns the time. |
void |
writeTo(QDataStream arg__1)
|
char |
zeroDigit()
Returns the zero digit character of this locale. |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QLocale()
QLocale
object initialized with the default locale. If no default locale was set using setDefaultLocale(), this locale will be the same as the one returned by system()
. setDefault()
.
public QLocale(QLocale.Language language)
QLocale
object with the specified language and country. QLocale
defaults to the default locale (see setDefault()
).language()
and country()
. setDefault()
, language()
, and country()
.
public QLocale(QLocale.Language language, QLocale.Country country)
QLocale
object with the specified language and country. QLocale
defaults to the default locale (see setDefault()
).language()
and country()
. setDefault()
, language()
, and country()
.
public QLocale(QLocale other)
QLocale
object as a copy of other.
public QLocale(java.lang.String name)
QLocale
object with the specified name, which has the format "language[_country][.codeset][@modifier]" or "C", where: The language and country codes are converted to their respective Language and Country enums. After this conversion is performed the constructor behaves exactly like QLocale
(Country, Language).
This constructor is much slower than QLocale
(Country, Language).
name()
.
Method Detail |
---|
public final QLocale.Country country()
language()
, countryToString()
, and name()
.
public final java.lang.String dateFormat()
If format is ShortFormat
the format will be a short version. Otherwise it uses a longer version.
QDate::toString()
, and QDate::fromString()
.
public final java.lang.String dateFormat(QLocale.FormatType format)
If format is ShortFormat
the format will be a short version. Otherwise it uses a longer version.
QDate::toString()
, and QDate::fromString()
.
public final java.lang.String dateTimeFormat()
If format is ShortFormat
the format will be a short version. Otherwise it uses a longer version.
QDateTime::toString()
, and QDateTime::fromString()
.
public final java.lang.String dateTimeFormat(QLocale.FormatType format)
If format is ShortFormat
the format will be a short version. Otherwise it uses a longer version.
QDateTime::toString()
, and QDateTime::fromString()
.
public final java.lang.String dayName(int arg__1)
monthName()
.
public final java.lang.String dayName(int arg__1, QLocale.FormatType format)
monthName()
.
public final char decimalPoint()
public final char exponential()
public final char groupSeparator()
public final QLocale.Language language()
country()
, languageToString()
, and name()
.
public final QLocale.MeasurementSystem measurementSystem()
public final java.lang.String monthName(int arg__1)
dayName()
.
public final java.lang.String monthName(int arg__1, QLocale.FormatType format)
dayName()
.
public final java.lang.String name()
language_country
", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two-letter ISO 3166 country code. language()
, and country()
.
public final char negativeSign()
public final QLocale.NumberOptions numberOptions()
QLocale
instance. By default, no options are set for the standard locales.
setNumberOptions()
.
public final void writeTo(QDataStream arg__1)
public final void readFrom(QDataStream arg__1)
public final char percent()
public final void setNumberOptions(QLocale.NumberOption[] options)
QLocale
instance. numberOptions()
.
public final void setNumberOptions(QLocale.NumberOptions options)
QLocale
instance. numberOptions()
.
public final java.lang.String timeFormat()
If format is ShortFormat
the format will be a short version. Otherwise it uses a longer version.
QTime::toString()
, and QTime::fromString()
.
public final java.lang.String timeFormat(QLocale.FormatType format)
If format is ShortFormat
the format will be a short version. Otherwise it uses a longer version.
QTime::toString()
, and QTime::fromString()
.
public final QDate toDate(java.lang.String string)
dateFormat()
). If the date could not be parsed, returns an invalid date.
dateFormat()
, toTime()
, toDateTime()
, and QDate::fromString()
.
public final QDate toDate(java.lang.String string, QLocale.FormatType arg__2)
dateFormat()
). If the date could not be parsed, returns an invalid date.
dateFormat()
, toTime()
, toDateTime()
, and QDate::fromString()
.
public final QDate toDate(java.lang.String string, java.lang.String format)
QDate::fromString()
for information on the expressions that can be used with this function. This function searches month names and the names of the days of the week in the current locale.
If the date could not be parsed, returns an invalid date.
dateFormat()
, toTime()
, toDateTime()
, and QDate::fromString()
.
public final QDateTime toDateTime(java.lang.String string)
dateTimeFormat()
). If the string could not be parsed, returns an invalid QDateTime
.
dateTimeFormat()
, toTime()
, toDate()
, and QDateTime::fromString()
.
public final QDateTime toDateTime(java.lang.String string, QLocale.FormatType format)
dateTimeFormat()
). If the string could not be parsed, returns an invalid QDateTime
.
dateTimeFormat()
, toTime()
, toDate()
, and QDateTime::fromString()
.
public final QDateTime toDateTime(java.lang.String string, java.lang.String format)
QDateTime::fromString()
for information on the expressions that can be used with this function. This function searches month names and the names of the days of the week in the current locale.
If the string could not be parsed, returns an invalid QDateTime
.
dateTimeFormat()
, toTime()
, toDate()
, and QDateTime::fromString()
.
public final java.lang.String toString(QDate date)
public final java.lang.String toString(QDate date, QLocale.FormatType format)
public final java.lang.String toString(QDate date, java.lang.String formatStr)
public final java.lang.String toString(QDateTime dateTime)
public final java.lang.String toString(QDateTime dateTime, QLocale.FormatType format)
public final java.lang.String toString(QDateTime dateTime, java.lang.String format)
public final java.lang.String toString(QTime time)
public final java.lang.String toString(QTime time, QLocale.FormatType format)
public final java.lang.String toString(QTime time, java.lang.String formatStr)
public final java.lang.String toString(double i, byte f)
public final java.lang.String toString(double i)
public final java.lang.String toString(double i, byte f, int prec)
public final java.lang.String toString(float i, byte f)
public final java.lang.String toString(float i)
public final java.lang.String toString(float i, byte f, int prec)
public final java.lang.String toString(int i)
public final java.lang.String toString(long i)
public final java.lang.String toString(char i)
public final QTime toTime(java.lang.String string)
timeFormat()
). If the time could not be parsed, returns an invalid time.
timeFormat()
, toDate()
, toDateTime()
, and QTime::fromString()
.
public final QTime toTime(java.lang.String string, QLocale.FormatType arg__2)
timeFormat()
). If the time could not be parsed, returns an invalid time.
timeFormat()
, toDate()
, toDateTime()
, and QTime::fromString()
.
public final QTime toTime(java.lang.String string, java.lang.String format)
QTime::fromString()
for information on what is a valid format string. If the time could not be parsed, returns an invalid time.
timeFormat()
, toDate()
, toDateTime()
, and QTime::fromString()
.
public final char zeroDigit()
public static QLocale c()
QLocale
object initialized to the "C" locale. system()
.
public static java.util.List countriesForLanguage(QLocale.Language lang)
public static java.lang.String countryToString(QLocale.Country country)
country()
, and name()
.
public static java.lang.String languageToString(QLocale.Language language)
countryToString()
, and name()
.
public static void setDefault(QLocale locale)
QLocale
object is constructed with no arguments. If this function is not called, the system's locale is used. Warning: In a multithreaded application, the default locale should be set at application startup, before any non-GUI threads are created.
system()
, and c()
.
public static QLocale system()
QLocale
object initialized to the system locale. On Windows and Mac, this locale will use the decimal/grouping characters and date/time formats specified in the system configuration panel.
c()
.
public static QLocale fromNativePointer(QNativePointer nativePointer)
public static QNativePointer nativePointerArray(QLocale[] array)
public final double toDouble(java.lang.String s)
public final float toFloat(java.lang.String s)
public final int toInt(java.lang.String s, int base)
public final int toInt(java.lang.String s)
public final long toLong(java.lang.String s, int base)
public final long toLong(java.lang.String s)
public final short toShort(java.lang.String s, int base)
public final short toShort(java.lang.String s)
public final char toChar(java.lang.String s, int base)
public final char toChar(java.lang.String s)
public QLocale clone()
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |