Package com.google.gwt.i18n.client

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


    private boolean isValidDate(String value, String format)
    {
        boolean isValid = false;
        try
        {
            DateTimeFormat df = DateTimeFormat.getFormat(format);
            df.parseStrict(value);
            isValid = true;
        }
        catch (IllegalArgumentException e)
        {
        }
View Full Code Here


          } else if (type.equals(Date.class)) {
            if ("timestamp".equals(field.getFormat())) {
              Date d = new Date(Long.parseLong(v) * 1000);
              model.set(name, d);
            } else {
              DateTimeFormat format = DateTimeFormat.getFormat(field.getFormat());
              Date d = format.parse(v);
              model.set(name, d);
            }
          }
        } else {
          model.set(field.getName(), v);
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;
    }
   
    date = new DateWrapper(date).resetTime().asDate();

    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

    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

            if (type.equals(Date.class)) {
              if ("timestamp".equals(field.getFormat())) {
                Date d = new Date(Long.parseLong(s) * 1000);
                model.set(name, d);
              } else {
                DateTimeFormat format = DateTimeFormat.getFormat(field.getFormat());
                Date d = format.parse(s);
                model.set(name, d);
              }
            }
          } else {
            model.set(name, s);
View Full Code Here

    if (val != null && val instanceof Number && c.getNumberFormat() != null) {
      Number n = (Number) val;
      val = c.getNumberFormat().format(n.doubleValue());
    } else if (val != null && val instanceof Date && 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

            }
        } );

        // Check if there is a valid date set. If not, set this date.
        try {
            DateTimeFormat formatter = DateTimeFormat.getFormat( defaultFormat );
            Date date = formatter.parse( selectedDate );
            selectedDate = visualFormatFormatter.format( date );
        } catch ( Exception e ) {
            selectedDate = visualFormatFormatter.format( new Date() );
        }
View Full Code Here

        if(Integer.parseInt(hh.getValue())==0 &&
        Integer.parseInt(mm.getValue())==0 &&
        Integer.parseInt(ss.getValue())==0){throw new Exception();}

        // cambio formato data (es. con formato Standard: Wed Jun 26 17:41:38 CEST 2013)
        DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy");
       
        // la stringa sTime sar� nulla nel caso in cui si decida di recuperare il momento dell'inserimento
        // dal Server, altrimenti avr� un formato simile al DateTime
        sTime = "&"+format.format(data.getValue())+"&"+hh.getText()+":"+mm.getText()+":"+ss.getText();
        }else{
        // il server si occupa di effettuare un controllo sul formato di sTime: nel caso in cui il suo
        // formato non sia 'HH:mm:ss' l'orario di inserimento viene preso da quello attuale del Server
          sTime = "";
        }
View Full Code Here

   *
   * @param hour
   * @return true if "hour" is hour false otherwise.
   */
  public  static  boolean isHourLegal(String hour) {
    DateTimeFormat simple = DateTimeFormat.getFormat("HH:mm:ss");
    try{
    simple.parse(hour);
    }
     catch (IllegalArgumentException e) {
     
      return false;
    }
View Full Code Here

    return true;
  }

  public  static  boolean isDateLegal(String date) {

    DateTimeFormat simple = DateTimeFormat.getFormat("dd/MM/yyyy");

    try {
      simple.parse(date);
      return true;
    } catch( IllegalArgumentException e ){
      return false;
    }
  }
View Full Code Here

TOP

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

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.