import java.text.DateFormatSymbols; public String getMonth(int month) { return new DateFormatSymbols().getMonths()[month-1]; }
String getMonthForInt(int num) { String month = "wrong"; DateFormatSymbols dfs = new DateFormatSymbols(); String[] months = dfs.getMonths(); if (num >= 0 && num <= 11 ) { month = months[num]; } return month; }
/** * Gets the {@link DateFormatSymbols} based on the given locale. * <p> * If JDK 6 or newer is being used, DateFormatSymbols.getInstance(locale) will * be used in order to allow the use of locales defined as extensions. * Otherwise, new DateFormatSymbols(locale) will be used. * See JDK 6 {@link DateFormatSymbols} for further information. * * @param locale the {@link Locale} used to get the correct {@link DateFormatSymbols} * @return the symbols * @since 2.0 */ public static final DateFormatSymbols getDateFormatSymbols(Locale locale) { try { Method method = DateFormatSymbols.class.getMethod("getInstance", new Class[] {Locale.class}); return (DateFormatSymbols) method.invoke(null, new Object[] {locale}); } catch (Exception ex) { return new DateFormatSymbols(locale); } }
public DateTimeDateFormat() { super(); shortMonths = new DateFormatSymbols().getShortMonths(); }
/** * Returns a new {@code DateFormatSymbols} for the given locale. * * @param locale the locale * @return an instance of {@code DateFormatSymbols} * @throws NullPointerException if {@code locale == null} * @since 1.6 */ public static final DateFormatSymbols getInstance(Locale locale) { if (locale == null) { throw new NullPointerException("locale == null"); } return new DateFormatSymbols(locale); }
public ConstantData() { super(); nf = NumberFormat.getInstance(); df = (DecimalFormat) nf; dfs = new DecimalFormatSymbols(); daf = new SimpleDateFormat(); dafs = new DateFormatSymbols(); }
/** * Gets the {@link DateFormatSymbols} based on the given locale. * <p> * If JDK 6 or newer is being used, DateFormatSymbols.getInstance(locale) will * be used in order to allow the use of locales defined as extensions. * Otherwise, new DateFormatSymbols(locale) will be used. * See JDK 6 {@link DateFormatSymbols} for further information. * * @param locale the {@link Locale} used to get the correct {@link DateFormatSymbols} * @return the symbols * @since 2.0 */ public static final DateFormatSymbols getDateFormatSymbols(Locale locale) { try { Method method = DateFormatSymbols.class.getMethod("getInstance", new Class[] {Locale.class}); return (DateFormatSymbols) method.invoke(null, new Object[] {locale}); } catch (Exception ex) { return new DateFormatSymbols(locale); } }
/** * Gets the {@link DateFormatSymbols} based on the given locale. * <p> * If JDK 6 or newer is being used, DateFormatSymbols.getInstance(locale) will * be used in order to allow the use of locales defined as extensions. * Otherwise, new DateFormatSymbols(locale) will be used. * See JDK 6 {@link DateFormatSymbols} for further information. * * @param locale the {@link Locale} used to get the correct {@link DateFormatSymbols} * @return the symbols * @since 2.0 */ public static final DateFormatSymbols getDateFormatSymbols(Locale locale) { try { Method method = DateFormatSymbols.class.getMethod("getInstance", new Class[] {Locale.class}); return (DateFormatSymbols) method.invoke(null, new Object[] {locale}); } catch (Exception ex) { return new DateFormatSymbols(locale); } }
/** * */ public AddXMLData() { super(); nf = NumberFormat.getInstance(); df = (DecimalFormat) nf; dfs = new DecimalFormatSymbols(); defaultDecimalFormat = (DecimalFormat) NumberFormat.getInstance(); defaultDecimalFormatSymbols = new DecimalFormatSymbols(); daf = new SimpleDateFormat(); dafs = new DateFormatSymbols(); defaultDateFormat = new SimpleDateFormat(); defaultDateFormatSymbols = new DateFormatSymbols(); }
public TextFileOutputData() { super(); nf = NumberFormat.getInstance(); df = (DecimalFormat) nf; dfs = new DecimalFormatSymbols(); daf = new SimpleDateFormat(); dafs = new DateFormatSymbols(); defaultDecimalFormat = (DecimalFormat) NumberFormat.getInstance(); defaultDecimalFormatSymbols = new DecimalFormatSymbols(); defaultDateFormat = new SimpleDateFormat(); defaultDateFormatSymbols = new DateFormatSymbols(); fileNameFieldIndex = -1; cmdProc = null; oneFileOpened = false; }
/** * */ public XMLOutputData() { super(); nf = NumberFormat.getInstance(); df = (DecimalFormat) nf; dfs = new DecimalFormatSymbols(); defaultDecimalFormat = (DecimalFormat) NumberFormat.getInstance(); defaultDecimalFormatSymbols = new DecimalFormatSymbols(); daf = new SimpleDateFormat(); dafs = new DateFormatSymbols(); defaultDateFormat = new SimpleDateFormat(); defaultDateFormatSymbols = new DateFormatSymbols(); OpenedNewFile = false; }
/** * This method is called at class initialization time to define the * value for constant member DEFAULT_PATTERN_CHARS. All other methods needing * this data should just read that constant. */ private static String initDefaultChars() { final DateFormatSymbols defaultSymbols = new DateFormatSymbols(Locale.US); return defaultSymbols.getLocalPatternChars(); }
/** * This method is called at class initialization time to define the * value for constant member DEFAULT_PATTERN_CHARS. All other methods needing * this data should just read that constant. */ private static String initDefaultChars() { final DateFormatSymbols defaultSymbols = new DateFormatSymbols(Locale.US); return defaultSymbols.getLocalPatternChars(); }
DateFormatSymbols symbols = new DateFormatSymbols(new Locale("it")); // for the current Locale : // DateFormatSymbols symbols = new DateFormatSymbols(); String[] dayNames = symbols.getShortWeekdays(); for (String s : dayNames) { System.out.print(s + " "); } // output : dom lun mar mer gio ven sab
/** * Constructs a new {@code SimpleDateFormat} for formatting and parsing * dates and times in the {@code SHORT} style for the user's default locale. * See "<a href="../util/Locale.html#default_locale">Be wary of the default locale</a>". */ public SimpleDateFormat() { this(Locale.getDefault()); this.pattern = defaultPattern(); this.formatData = new DateFormatSymbols(Locale.getDefault()); }
public class Timeis { public static void main(String s[]) { long ts = 1022895271767L; SimpleDateFormat sdf = new SimpleDateFormat(" MMM d 'at' hh:mm a"); // CREATE DateFormatSymbols WITH ALL SYMBOLS FROM (DEFAULT) Locale DateFormatSymbols symbols = new DateFormatSymbols(Locale.getDefault()); // OVERRIDE SOME symbols WHILE RETAINING OTHERS symbols.setAmPmStrings(new String[] { "am", "pm" }); sdf.setDateFormatSymbols(symbols); String st = sdf.format(ts); System.out.println("time is " + st); } }
public static Date str2dat( String arg0, String arg1, String val ) throws KettleValueException { SimpleDateFormat df = new SimpleDateFormat(); DateFormatSymbols dfs = new DateFormatSymbols(); if ( arg1 != null ) { dfs.setLocalPatternChars( arg1 ); } if ( arg0 != null ) { df.applyPattern( arg0 ); } try { return df.parse( val ); } catch ( Exception e ) { throw new KettleValueException( "TO_DATE Couldn't convert String to Date " + e.toString() ); } }
public static String formatDateAsString(Date date) { // format date list grid cells SimpleDateFormat formatter = new SimpleDateFormat("MMM d, Y @ hh:mma"); DateFormatSymbols symbols = new DateFormatSymbols(Locale.getDefault()); symbols.setAmPmStrings(new String[] { "am", "pm" }); formatter.setDateFormatSymbols(symbols); return formatter.format(date); }
/** * Constructs a new {@code SimpleDateFormat} using the specified * non-localized pattern and the {@code DateFormatSymbols} and {@code * Calendar} for the specified locale. * * @param template * the pattern. * @param locale * the locale. * @throws NullPointerException * if the pattern is {@code null}. * @throws IllegalArgumentException * if the pattern is invalid. */ public SimpleDateFormat(String template, Locale locale) { this(locale); validatePattern(template); pattern = template; formatData = new DateFormatSymbols(locale); }
public DateFormatSymbolsEx(Locale locale) { DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale); months = dateFormatSymbols.getMonths(); shortMonths = dateFormatSymbols.getShortMonths(); weekdays = dateFormatSymbols.getWeekdays(); shortWeekdays = dateFormatSymbols.getShortWeekdays(); eras = dateFormatSymbols.getEras(); ampms = dateFormatSymbols.getAmPmStrings(); }