Package com.ibm.icu.text

Examples of com.ibm.icu.text.SimpleDateFormat


 
  public IValue printDateTimeInLocale(IDateTime inputDateTime, IString formatString, IString locale)
  //@doc{Print an input datetime using a specific locale and format string}
  {
    try {
      SimpleDateFormat sd = new SimpleDateFormat(formatString.getValue(),new ULocale(locale.getValue()));
      Calendar cal = getCalendarForDateTime(inputDateTime);
      sd.setCalendar(cal);
      return values.string(sd.format(cal.getTime()));
    } catch (IllegalArgumentException iae) {
      throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print datetime using format string: " + formatString.getValue() +
          " in locale: " + locale.getValue(), null, null);
    }
  }
View Full Code Here


  public IValue printDateTimeInLocale(IDateTime inputDateTime, IString locale)
  //@doc{Print an input datetime using a specific locale and a default format string}
  {
    try {
      SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ",new ULocale(locale.getValue()));
      Calendar cal = getCalendarForDateTime(inputDateTime);
      sd.setCalendar(cal);
      return values.string(sd.format(cal.getTime()));
    } catch (IllegalArgumentException iae) {
      throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print datetime in locale: " + locale.getValue(), null, null);
    }
  }
View Full Code Here

        String productStoreId = (String) context.get("productStoreId");
        try {
            Calendar fromDate = Calendar.getInstance();
            Calendar toDate = Calendar.getInstance();
            if (UtilValidate.isNotEmpty(context.get("thruDate"))) {
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                dateFormat.parse(context.get("fromDate").toString());
                fromDate.setTime(dateFormat.parse(context.get("fromDate").toString()));

                SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                dateFormat2.parse(context.get("thruDate").toString());
                toDate.setTime(dateFormat.parse(context.get("thruDate").toString()));
            } else {
                toDate.setTime(UtilDateTime.nowDate());
                fromDate = null;
            }
View Full Code Here

        ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
        try {
            Calendar fromDate = Calendar.getInstance();
            Calendar toDate = Calendar.getInstance();
            if (UtilValidate.isNotEmpty(context.get("thruDate"))) {
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                dateFormat.parse(context.get("fromDate").toString());
                fromDate.setTime(dateFormat.parse(context.get("fromDate").toString()));

                SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                dateFormat2.parse(context.get("thruDate").toString());
                toDate.setTime(dateFormat.parse(context.get("thruDate").toString()));
            } else {
                toDate.setTime(UtilDateTime.nowDate());
                fromDate = null;
            }
View Full Code Here

        }
        return isReserve;
    }

    public static String convertDate(Date date, Locale locale) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",locale);
        return simpleDateFormat.format(date);
    }
View Full Code Here

        this.variant = DATE;
        this.localizedPatterns = new LocaleMap();
    }

    public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
        SimpleDateFormat dateFormat = getDateFormat(locale, formatCache);
        try {
            return new ConversionResult(dateFormat.parse(value));
        } catch (ParseException e) {
            return ConversionResult.create("date." + this.variant);
        }
    }
View Full Code Here

            return ConversionResult.create("date." + this.variant);
        }
    }

    public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
        SimpleDateFormat dateFormat = getDateFormat(locale, formatCache);
        return dateFormat.format((Date)value);
    }
View Full Code Here

        SimpleDateFormat dateFormat = getDateFormat(locale, formatCache);
        return dateFormat.format((Date)value);
    }

    private final SimpleDateFormat getDateFormat(Locale locale, Convertor.FormatCache formatCache) {
        SimpleDateFormat dateFormat = null;
        if (formatCache != null)
            dateFormat = (SimpleDateFormat)formatCache.get();
        if (dateFormat == null) {
            dateFormat = getDateFormat(locale);
            if (formatCache != null)
View Full Code Here

        }
        return dateFormat;
    }

    protected SimpleDateFormat getDateFormat(Locale locale) {
        SimpleDateFormat dateFormat = null;

        if (this.variant.equals(DATE)) {
            //dateFormat = I18nSupport.getInstance().getDateFormat(style, locale);
            dateFormat = (SimpleDateFormat)DateFormat.getDateInstance(style, locale);
        } else if (this.variant.equals(TIME)) {
            //dateFormat = I18nSupport.getInstance().getTimeFormat(style, locale);
            dateFormat = (SimpleDateFormat)DateFormat.getTimeInstance(style, locale);
        } else if (this.variant.equals(DATE_TIME)) {
            //dateFormat = I18nSupport.getInstance().getDateTimeFormat(style, style, locale);
            dateFormat = (SimpleDateFormat)DateFormat.getDateTimeInstance(style, style, locale);
        }

        String pattern = (String)localizedPatterns.get(locale);

        if (pattern != null)
            // Note: this was previously using applyLocalizedPattern() which allows to use
            // a locale-specific pattern syntax, e.g. in french "j" (jour) for "d" and
            // "a" (annee) for "y". But the localized pattern syntax is very little known and thus
            // led to some weird pattern syntax error messages.
            dateFormat.applyPattern(pattern);
        else if (nonLocalizedPattern != null)
            dateFormat.applyPattern(nonLocalizedPattern);

        return dateFormat;
    }
View Full Code Here

  @Override
  protected void doRun() {
    cacheManager.initCache();
   
    if (!goalsAndPrinciplesOnly)
      gssQuery.setTimestamp(new SimpleDateFormat("MM.dd.yyyy HH:mm:ss z").format(new Date()));
   
    preselector.runWithoutUnicaseCommand();
   
    if (!goalsAndPrinciplesOnly)
    ratingsCalculator.runWithoutUnicaseCommand();
View Full Code Here

TOP

Related Classes of com.ibm.icu.text.SimpleDateFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.