Package com.google.gwt.i18n.client

Examples of com.google.gwt.i18n.client.DateTimeFormat$PatternPart


    Button updateButton;
    private ContactInfo contactInfo;

    public ContactInfoForm() {
        initWidget(uiBinder.createAndBindUi(this));
        DateTimeFormat dateFormat = DateTimeFormat.getFormat(
                PredefinedFormat.DATE_LONG);
        birthdayBox.setFormat(new DateBox.DefaultFormat(dateFormat));

        // Add the categories to the category box.
        final Category[] categories = ContactDatabase.get().queryCategories();
View Full Code Here


  private ContactInfo contactInfo;

  public ContactInfoForm() {
    initWidget(uiBinder.createAndBindUi(this));
    DateTimeFormat dateFormat = DateTimeFormat.getFormat(
        PredefinedFormat.DATE_LONG);
    birthdayBox.setFormat(new DateBox.DefaultFormat(dateFormat));

    // Add the categories to the category box.
    final Category[] categories = ContactDatabase.get().queryCategories();
View Full Code Here

  private static Date date = new Date(0);

  public static double parse(String fmt, String dateString) {
    date.setTime(0);
    if(fmt == null) return Date.parse(dateString);
    DateTimeFormat dtf = DateTimeFormat.getFormat(fmt);
    dtf.parse(dateString, 0, date);
    return date.getTime();
  }
View Full Code Here

* Tests {@link OsapiRequestBuilder}.
*/
public class OsapiRequestTest extends GadgetsOsapiTestCase {

  public void testOsapiRequest_updatedSince() {
    DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-MM-dd'T'hh:mm:ss.SSSS");
    String date = "2010-06-21T12:30:00.0000";

    setUpdatedSinceMock(date);
    asAsync();

    PeopleService people = PeopleService.getInstance();
    GetPersonRequestBuilder builder = people.newGetOwnerRequestBuilder();
    builder.setUpdatedSince(dtf.parse(date));
    builder.build().execute(new Callback<Person>() {
      public void onFail(OsapiError error) {
        fail();
      }

View Full Code Here

    if (value.length() < 1) { // if it's blank and textfield didn't flag it then
      // it's valid
      return true;
    }

    DateTimeFormat format = getPropertyEditor().getFormat();

    Date date = null;

    try {
      date = getPropertyEditor().convertStringValue(value);
    } catch (Exception e) {

    }

    if (date == null) {
      String error = null;
      if (getMessages().getInvalidText() != null) {
        error = Format.substitute(getMessages().getInvalidText(), value, format.getPattern().toUpperCase());
      } else {
        error = GXT.MESSAGES.dateField_invalidText(value, format.getPattern().toUpperCase());
      }
      markInvalid(error);
      return false;
    }

    if (minValue != null && date.before(minValue)) {
      String error = null;
      if (getMessages().getMinText() != null) {
        error = Format.substitute(getMessages().getMinText(), format.format(minValue));
      } else {
        error = GXT.MESSAGES.dateField_minText(format.format(minValue));
      }
      markInvalid(error);
      return false;
    }
    if (maxValue != null && date.after(maxValue)) {
      String error = null;
      if (getMessages().getMaxText() != null) {
        error = Format.substitute(getMessages().getMaxText(), format.format(maxValue));
      } else {
        error = GXT.MESSAGES.dateField_maxText(format.format(maxValue));
      }
      markInvalid(error);
      return false;
    }
View Full Code Here

         * not the same as the browser locale
         */
        formatStr = formatMonthNames(date, formatStr);

        // Format uses the browser locale
        DateTimeFormat format = DateTimeFormat.getFormat(formatStr);

        String result = format.format(date);

        return result;
    }
View Full Code Here

     *
     */
    public Date parseDate(String dateString, String formatString,
            boolean lenient) throws IllegalArgumentException {
        /* DateTimeFormat uses the browser's locale */
        DateTimeFormat format = DateTimeFormat.getFormat(formatString);

        /*
         * Parse month names separately when locale for the DateTimeService is
         * not the same as the browser locale
         */
        dateString = parseMonthName(dateString, formatString);

        Date date;

        if (lenient) {
            date = format.parse(dateString);
        } else {
            date = format.parseStrict(dateString);
        }

        // Some version of Firefox sets the timestamp to 0 if parsing fails.
        if (date != null && date.getTime() == 0) {
            throw new IllegalArgumentException("Parsing of '" + dateString
View Full Code Here

    if (val != null && c.getNumberFormat() != null) {
      Number n = (Number) val;
      NumberFormat nf = cm.getColumn(colIndex).getNumberFormat();
      val = nf.format(n.doubleValue());
    } else if (val != null && c.getDateTimeFormat() != null) {
      DateTimeFormat dtf = c.getDateTimeFormat();
      val = dtf.format((Date) val);
    }

    String text = null;
    if (val != null) {
      text = val.toString();
View Full Code Here

    return formatDate( getNativeNextRun() );
  }

  public static Date formatDate( String dateStr ) {
    try {
      DateTimeFormat format = DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 );
      return format.parse( dateStr );
    } catch ( Throwable t ) {
      //ignored
    }

    try {
      DateTimeFormat format = DateTimeFormat.getFormat( "yyyy-MM-dd'T'HH:mm:ssZZZ" );
      return format.parse( dateStr );
    } catch ( Throwable t ) {
      //ignored
    }

    return null;
View Full Code Here

  public boolean isValid() {
    boolean isValid = true;
    if ( null == editor.getStartDate() ) {
      isValid = false;
    } else {
      final DateTimeFormat format = DateTimeFormat.getFormat( "MM-dd-yyyy" ); //$NON-NLS-1$
      final String date = format.format( editor.getStartDate() );
      final String dateTime = date + " " + editor.getStartTime(); //$NON-NLS-1$

      if ( DateTimeFormat.getFormat( "MM-dd-yyyy hh:mm:ss a" ).parse( dateTime ).before( new Date() ) ) { //$NON-NLS-1$
        isValid = false;
      }
View Full Code Here

TOP

Related Classes of com.google.gwt.i18n.client.DateTimeFormat$PatternPart

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.