swisseph
Class Extlib

java.lang.Object
  extended by swisseph.Extlib

public class Extlib
extends java.lang.Object

Some supportive methods, mainly for internationalization. These methods are not available in the original Swiss Ephemeris package.


Constructor Summary
Extlib()
          This class contains some additional method not contained in the original Swiss Ephemeris package.
 
Method Summary
 java.text.SimpleDateFormat createLocDateTimeFormatter(java.lang.String locString, boolean force24h)
          Creates a localized date time formatter suitable for tabular output with 4 digit years and UTC timezone.
 java.lang.String getDecimalSeparator(java.text.NumberFormat nf)
          Returns the decimal separator of the NumberFormat
 java.util.Locale getLocale(java.lang.String locString)
          Returns the requested locale from a locale string.
 java.lang.String[] getLocales()
          This method returns all available locale strings
 java.lang.String getNormalizedDatePattern(java.lang.String pattern, boolean force24h)
          Ensures a date pattern with four letter year, two letter month and day and 24h time format, if requested.
 int getPatternLastIdx(java.lang.String pattern, java.lang.String what, java.text.SimpleDateFormat dof)
          Returns the index in the formatter pattern of the given pattern 'what' recalculated to the APPLIED pattern of the formatter.
static void main(java.lang.String[] argv)
          This method is for debugging purposes only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Extlib

public Extlib()
This class contains some additional method not contained in the original Swiss Ephemeris package. Currently, these methods deal with internationalization primarily.

Method Detail

main

public static void main(java.lang.String[] argv)
This method is for debugging purposes only.


getLocales

public java.lang.String[] getLocales()
This method returns all available locale strings


getLocale

public java.util.Locale getLocale(java.lang.String locString)
Returns the requested locale from a locale string.

Parameters:
locString - A String describing the locale as a two letter language code, a two letter language code plus a "_" plus a two letter country code, or null or the empty string. Null or the empty string will return the default locale, all others will return the requested locale.
Returns:
The locale

createLocDateTimeFormatter

public java.text.SimpleDateFormat createLocDateTimeFormatter(java.lang.String locString,
                                                             boolean force24h)
Creates a localized date time formatter suitable for tabular output with 4 digit years and UTC timezone. You will format dates like this:

    SimpleDateFormat sdf = createLocDateTimeFormatter("da_DK", true);
   SweDate sd = new SweDate(2005,3,27);
   //...
   System.out.println(sdf.format(sd.getDate(0)));

Years B.C. will be prefixed by a "-". Years are counted including year "0", which differs from normal DateFormat output.

Parameters:
locString - The input locale for which this date time format should be created. See getLocale() for more infos.
Returns:
The normalized form of the DateFormat.

getNormalizedDatePattern

public java.lang.String getNormalizedDatePattern(java.lang.String pattern,
                                                 boolean force24h)
Ensures a date pattern with four letter year, two letter month and day and 24h time format, if requested.


getDecimalSeparator

public java.lang.String getDecimalSeparator(java.text.NumberFormat nf)
Returns the decimal separator of the NumberFormat


getPatternLastIdx

public int getPatternLastIdx(java.lang.String pattern,
                             java.lang.String what,
                             java.text.SimpleDateFormat dof)
Returns the index in the formatter pattern of the given pattern 'what' recalculated to the APPLIED pattern of the formatter. E.g. for locale zh_HK the pattern is: yyyy'年'MM'月'dd'日' ahh:mm:ss The index of 'ss' would NOT be 25, which we would get when simply counting in the pattern string, but rather 20, when counting in the resulting string.