|
jET |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.text.Format | +--prv.doman.util.DegreeFormat
Formats and parse angle with specified pattern.
It formats integer and floating-point numbers. The full output may look like these:
23°35′03.234″
1,567°0′59″
0°00.500′
-24.75°
90°
So output seems to have at most four fields: degrees, minutes, seconds and
the fractional part of seconds. Note that symbols ′
and ″
aren't the ASCII Quotation Mark (Unicode \u0022
) and Apostrophe (Unicode
\u0027
), but Mathematical symbols: Prime (Unicode \u2033
)
and Double Prime (Unicode \u2032
). Note that decimal separators and fraction dot
might be localized.
The right order in format must be as follows: degrees, minutes, seconds. The fractional part is always at the and of output and it is optional. Optional are minutes and seconds also, but it is not possible to have format for examaple: degrees and seconds without minutes.
The parttern is a string containing characters with special meanings:
D The integer part of degree field. d The fractional part of degree field. M The integer part of minute field. m The fractional part of minute field. S The integer part of second fields. s The fractional part of second field. . Fractional separator (localized). ° (Unicode \u00B0) Degree symbol. ′ (Unicode \u2032) Minute symbol ″ (Unicode \u2033) Second symbol.
Here are some expamples of patterns:
Pattern Examples D° 360° 2° DDD.dd° 008.55° 241.08° D°M.m′ 123°20.2′ -3°2.0′ DDDMMSS 1803000 0030000
For symbol customization use class DegreeFormatSymbols
.
Field Summary | |
static int |
DEGREE_FIELD
The degree field. |
static int |
MINUTE_FIELD
The minute field. |
static int |
SECOND_FIELD
The second field. |
Constructor Summary | |
DegreeFormat()
Constructs degree format with default pattern and symbols. |
|
DegreeFormat(java.lang.String pattern)
Constructs degree format with specified pattern. |
|
DegreeFormat(java.lang.String pattern,
DegreeFormatSymbols symbols)
Constructs degree format with specified pattern and symbols. |
Method Summary | |
void |
applyPattern(java.lang.String pattern)
Applies pattern to this format. |
java.lang.String |
format(double number)
Formats simple double value. |
java.lang.StringBuffer |
format(double number,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
Formats floating point number using format's pattern and symbols. |
java.lang.String |
format(int number)
Formats integer value. |
java.lang.StringBuffer |
format(java.lang.Object obj,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
Tries to format object with output redirected to string buffer and with position. |
static java.util.Locale[] |
getAvailableLocales()
Returns all available locales in Java Virtual Machine. |
DegreeFormatSymbols |
getDegreeFormatSymbols()
Gets the format symbols of this format. |
static DegreeFormat |
getInstance()
Gets the instance of degree format class with default locale. |
static DegreeFormat |
getInstance(java.util.Locale locale)
Gets the instace of degree format class with specified locale. |
java.lang.Double |
parse(java.lang.String source,
java.text.ParsePosition parsePosition)
Parses string to find the double number representing. |
java.lang.Object |
parseObject(java.lang.String source,
java.text.ParsePosition parsePosition)
Parses string to find an object that representing value. |
void |
setDegreeFormatSymbols(DegreeFormatSymbols s)
Sets for this format symbols. |
java.lang.String |
toPattern()
Gets pattern of this format. |
Methods inherited from class java.text.Format |
clone, format, formatToCharacterIterator, parseObject |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEGREE_FIELD
public static final int MINUTE_FIELD
public static final int SECOND_FIELD
Constructor Detail |
public DegreeFormat()
D°MM′SS″
.
public DegreeFormat(java.lang.String pattern)
pattern
- Pattern string.public DegreeFormat(java.lang.String pattern, DegreeFormatSymbols symbols)
pattern
- Pattern string.symbols
- Custom symbols.Method Detail |
public void setDegreeFormatSymbols(DegreeFormatSymbols s)
s
- Degree format symbols.public DegreeFormatSymbols getDegreeFormatSymbols()
public void applyPattern(java.lang.String pattern)
pattern
- A pattern.
java.lang.IllegalArgumentException
- When pattern has illegal syntax.public java.lang.String toPattern()
public static final DegreeFormat getInstance()
D°MM″SS′
.
public static final DegreeFormat getInstance(java.util.Locale locale)
D°MM″SS′
.
locale
- lopublic static java.util.Locale[] getAvailableLocales()
public java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
format
in class java.text.Format
obj
- A number to format.toAppendTo
- String buffer where append to formatted output.pos
- Field position (unused).
java.lang.IllegalArgumentException
- When object is not a number.public java.lang.String format(double number)
number
- Floating point number to format.
public java.lang.String format(int number)
number
- Integer number to format.
public java.lang.StringBuffer format(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
number
- Floating point number going to be formatted.toAppendTo
- String buffer where to append.pos
- Field position (unused).
java.lang.NullPointerException
- When position or string buffer is null.public java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition parsePosition)
parseObject
in class java.text.Format
source
- String to parse.parsePosition
- Data structure of success or fail in parsing.
public java.lang.Double parse(java.lang.String source, java.text.ParsePosition parsePosition)
This method parses numbers:
DEGREES [ MINUTES [ SECONDS ] ]
source
- String to parse.parsePosition
- Data structure to inviligate parsing progress.
|
jET |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |