With the AHDateTime object you can format and parse date and time strings.
The B4A builtin DateTime object always uses localized format strings so it is not possible to parse something like "2011/05/19 01:45 PM" on a german device because "PM" is "nachm." there. You can Initialize the AHDateTime object with any locale you want and so you are totally free on date formats.
Formats a date or a time range according to the local conventions.
Note that this is a convenience method. Using it involves creating an internal Formatter instance on-the-fly, which is somewhat costly in terms of memory and time.
StartTicks - start time EndTicks - end time Flags - a bit mask of options
FormatDateTime (TicksAsLong, FlagsAsInt) AsString
Formats a date or a time according to the local conventions. There are lots of options that allow the caller to control, for example, if the time is shown, if the day of the week is shown, if the month name is abbreviated, if noon is shown instead of 12pm, and so on.
Ticks - time/date to format Flags - a bit mask of options
FormatElapsedTime (SecondsAsLong) AsString
Formats an elapsed time in the form "MM:SS" or "H:MM:SS" for display on the call-in-progress screen.
Return string describing the elapsed time since startTime formatted like "[relative time/date], [time]".
Ticks - some time in the past.
MinResolution - the minimum elapsed time (in milliseconds) to report when showing relative times. For example, a time 3 seconds in the past will be reported as "0 minutes ago" if this is set to MINUTE_IN_MILLIS.
TransitionResolution - the elapsed time (in milliseconds) at which to stop reporting relative measurements. Elapsed times greater than this resolution will default to normal date formatting. For example, will transition from "6 days ago" to "Dec 12" when using WEEK_IN_MILLIS.
Returns a string describing 'time' as a time relative to 'now'.
Time spans in the past are formatted like "42 minutes ago". Time spans in the future are formatted like "in 42 minutes". Can use FORMAT_ABBREV_RELATIVE flag to use abbreviated relative times, like "42 mins ago".
Ticks - the time to describe, in milliseconds
Now - the current time in milliseconds
MinResolution - the minimum timespan to report. For example, a time 3 seconds in the past will be reported as "0 minutes ago" if this is set to MINUTE_IN_MILLIS. Pass one of 0, MINUTE_IN_MILLIS, HOUR_IN_MILLIS, DAY_IN_MILLIS, WEEK_IN_MILLIS
Flags - a bit mask of formatting options, such as FORMAT_NUMERIC_DATE or FORMAT_ABBREV_RELATIVE
IsToday (TicksAsLong) AsBoolean
Returns true if the supplied Ticks value is today else false
Returns the array of strings which represent AM and PM.
AvailableLocalesAsList [read only]
Returns the system's installed locales. These are returned as a B4A List of AHLocale Objects. There are only locales in this list which have a non empty country and language.
CountryAsString [read only]
Returns the country/region code for this locale, which will either be the empty string or an uppercase ISO 3166 2-letter code.
CurrencyCodeAsString [read only]
Returns this currency's ISO 4217 currency code.
CurrencyFractionDigitsAsInt [read only]
Returns the default number of fraction digits for this currency.
CurrencySymbolAsString [read only]
Returns the localized currency symbol for this currency in locale.
DisplayCountryAsString [read only]
Returns the name of this locale's country, localized to locale. Returns the empty string if this locale does not correspond to a specific country
DisplayLanguageAsString [read only]
Returns the name of this locale's language, localized to locale. If the language name is unknown, the language code is returned.
DisplayNameAsString [read only]
Returns this locale's language name, country name, and variant, localized to locale. The exact output form depends on whether this locale corresponds to a specific language, country and variant, such as: English, English (United States), English (United States,Computer), anglais (?tats-Unis), anglais (?tats-Unis,informatique).
EnglishCountryAsString [read only]
Returns the name of this locale's country in english. Returns the empty string if this locale does not correspond to a specific country
EnglishLanguageAsString [read only]
Returns the name of this locale's language in english. If the language name is unknown, the language code is returned.
EnglishNameAsString [read only]
Returns this locale's language name, country name, and variant in english. The exact output form depends on whether this locale corresponds to a specific language, country and variant, such as: English, English (United States), English (United States,Computer), anglais (?tats-Unis), anglais (?tats-Unis,informatique).
FirstDayOfWeekAsInt [read only]
Gets the first day of the week
Initialize
Initializes the AHLocale object with the default locale.
Initialize2 (languageAsString)
Initializes the AHLocale object using the specified language.
Initialize3 (languageAsString, countryAsString)
Initializes the AHLocale object using the specified language and country.
InitializedAsBoolean [read only]
Returns if the object is initialized
InitializeUS
Initializes the AHLocale Object with en_US locale. This locale is available on every device.
ISO3CountryAsString [read only]
Gets the three letter ISO country code which corresponds to the country code for this Locale.
ISO3LanguageAsString [read only]
Gets the three letter ISO language code which corresponds to the language code for this Locale.
ISOCodeAsString [read only]
Returns the ISO Code for this Locale such as en_US or de_DE
ISOCountries() AsString [read only]
Gets the list of two letter ISO country codes which can be used as the country code for a Locale.
ISOLanguages() AsString [read only]
Gets the list of two letter ISO language codes which can be used as the language code for a Locale.
LanguageAsString [read only]
Gets the language code for this Locale or the empty string if no language was set.
Months() AsString [read only]
Returns the array of strings containing the full names of the months.
ShortMonths() AsString [read only]
Returns the array of strings containing the abbreviated names of the months.
ShortWeekDays() AsString [read only]
Returns the array of strings containing the abbreviated names of the days of the week.
WeekDays() AsString [read only]
Returns the array of strings containing the full names of the days of the week.
With the AHNumeric object you can format and parse numbers, currency values and percent values.
There are several Initialize methods to initialize different types of the object. These differ normally in the pattern that is applied to the NumberFormat object.
Returns a list of available timezone IDs on this device. One of the results can be passed to the Initialize2() Method to reinitialize an AHTimeZone object with a different timezone
DSTSavingsAsLong [read only]
Returns the daylight savings offset in milliseconds for this time zone. The base implementation returns 3600000 (1 hour) for time zones that use daylight savings time and 0 for timezones that do not. Note that this method doesn't tell you whether or not to apply the offset: you need to call InDaylightTime() for the specific time you're interested in. If this method returns a non-zero offset, that only tells you that this TimeZone sometimes observes daylight savings.
DaylightTime - Set to true if you want to have DST included into the name Style - AHTimeZone.SHORT or AHTimeZone.LONG format Locale - a AHLocale object to set in which language you want the displayname
GetOffset (DateAsLong) AsLong
Returns the offset in milliseconds from UTC for this time zone at time. The offset includes daylight savings time if the specified date is within the daylight savings time period.
Date - Date for which you want to have the info
IDAsString
Gets or sets the timezone ID as String for this timezone
InDaylightTime (DateAsLong) AsBoolean
Returns true if Date is in a daylight savings time period for this time zone.
Date - Date for which you want to get the info
Initialize
Initialize a AHTimeZone object with default timezone
Initialize2 (IDAsString)
Initializes a AHTimeZone object with the given TimeZone ID
With the Translator object you can make your programs support multiple languages. It is very easy to create translations for your program and use them.
Translation files have the following name convention: [basename]_[language].lng
The format is a standard Java properties file. Special characters should be converted to unicode sequences.
The translator object holds two Map Objects for the translations. One for the existing translations in the language file and one for missing translations in the language file. When you call GetText() with a string that is not in the translation file then it will be added to the missing translations Map.
Sets or gets the default language. This is the language used when no language file is found. If you don't set it the default language will be empty and is not used.
ExtensionAsString
Sets or gets the current file extension
GetText (textAsString) AsString
Searches for the text in the translation table. If a translation is available it will be returned. If no translation is available the text is added to the missing translation table and the original text is returned. So you can write your whole program in a default language. If a translation is available it will be used, if not, the text will be returned in the default language.
GetText2 (textAsString, paramsAsList) AsString
Searches for the text in the translation table and returns the translated text.
You can use Placeholders in the form of {1} {2} etc. which will be replaced with the content of the second parameter. {1} will be replaced with the first item in the Array/List, {2} with the second one and so on.
Initialize (dirAsString, basenameAsString)
Initializes a translation object with the device language. Tries to read a translation file with the following name convention: basename_language.lng
Initializes a translation object with the given language and country code. Tries to read a translation file with the following name convention: basename_language_country.lng
MissingTranslationMapAsMap [read only]
Returns a Map object with all text phrases which are missing in the translation file.
TranslationMapAsMap
Returns a Map object with the current translations
WriteTranslation (dirAsString, filenameAsString)
Writes two files to the specified dir. The current translation Map is written to [filename]_[language].lng and the missing translation Map is written to [filename]_miss_[language].lng
Top