Package javax.swing.text

Examples of javax.swing.text.MaskFormatter.stringToValue()


        // Checks to see if valid output is produced
        harness.checkPoint("valid output");
        formatter.setMask("(###) ###-####");
        harness.check (formatter.valueToString("(555) 807-9090"),"(555) 807-9090");
        harness.check (formatter.stringToValue("(555) 807-9090"),"(555) 807-9090");
        formatter.setValueContainsLiteralCharacters(false);
        harness.check (formatter.stringToValue("(555) 807-9090"),"5558079090");
        boolean exception = false;
        try
          {
View Full Code Here


        harness.checkPoint("valid output");
        formatter.setMask("(###) ###-####");
        harness.check (formatter.valueToString("(555) 807-9090"),"(555) 807-9090");
        harness.check (formatter.stringToValue("(555) 807-9090"),"(555) 807-9090");
        formatter.setValueContainsLiteralCharacters(false);
        harness.check (formatter.stringToValue("(555) 807-9090"),"5558079090");
        boolean exception = false;
        try
          {
            harness.check (formatter.valueToString("(555) 807-9090"),"(555) 807-9090");
          }
View Full Code Here

        // Checks to see if valid/invalid character sets work
        formatter = new MaskFormatter("T##'FA");       
        formatter.setInvalidCharacters("T");
        formatter.setValidCharacters("4");
        harness.check(formatter.valueToString("T44F4"), "T44F4");
        harness.check(formatter.stringToValue("T44F4"), "T44F4");
        exception = false;
        try
          {
            formatter.valueToString("T33F3");
          }
View Full Code Here

    String m = this.getMask();
    if(v != null && m != null) {
      try {
        MaskFormatter mf = new MaskFormatter(m);
        mf.setValueContainsLiteralCharacters(false);
        unmaskedValue = (String) mf.stringToValue(v);
        if(unmaskedValue != null) {
          // MaskFormatter leaves extra white space if it's too short, not good
          // for our purposes
          unmaskedValue = unmaskedValue.trim();
        }
View Full Code Here

  public String limpar(String valor, String mascara) {
    try {
      if (valor.length() == mascara.length()) {
        MaskFormatter formatter = new MaskFormatter(mascara);
        formatter.setValueContainsLiteralCharacters(false);
        valor = formatter.stringToValue(valor).toString();
      }
    } catch (ParseException e) {
      log.info(e.getMessage());
    }
    return valor;
View Full Code Here

   */
  public static Calendar convertStringHHMM2TimeCalendarTolerant(String toConvert) throws ParseException {
    if (toConvert != null) {
      // check if the string matches the mask
      MaskFormatter mf = new MaskFormatter(Converter.TIME_MASK);
      mf.stringToValue(toConvert);
      int pos = toConvert.indexOf(Converter.TIME_SEPARATOR);
      String h_str = toConvert.substring(0, pos);
      Integer h = new Integer(h_str);
      String min_str = toConvert.substring(pos + 1);
      Integer min = new Integer(min_str);
View Full Code Here

   */
  public static BigDecimal convertStringHHMM2BigDecimalTolerant(String toConvert) throws ParseException {
    if (toConvert != null) {
      // check if the string matches the mask
      MaskFormatter mf = new MaskFormatter(Converter.TIME_MASK);
      mf.stringToValue(toConvert);
      int pos = toConvert.indexOf(Converter.TIME_SEPARATOR);
      String h = toConvert.substring(0, pos);
      String m = toConvert.substring(pos + 1);
      BigDecimal t = new BigDecimal(m + ".00");
      t = t.divide(new BigDecimal("60.00"), BigDecimal.ROUND_HALF_UP);
View Full Code Here

     */
    public static Calendar convertStringHHMM2TimeCalendarTolerant(String toConvert) throws ParseException {
        if (toConvert != null) {
            // check if the string matches the mask
            MaskFormatter mf = new MaskFormatter(Converter.TIME_MASK);
            mf.stringToValue(toConvert);
            int pos = toConvert.indexOf(Converter.TIME_SEPARATOR);
            String h_str = toConvert.substring(0, pos);
            Integer h = new Integer(h_str);
            String min_str = toConvert.substring(pos + 1);
            Integer min = new Integer(min_str);
View Full Code Here

     */
    public static BigDecimal convertStringHHMM2BigDecimalTolerant(String toConvert) throws ParseException {
        if (toConvert != null) {
            // check if the string matches the mask
            MaskFormatter mf = new MaskFormatter(Converter.TIME_MASK);
            mf.stringToValue(toConvert);
            int pos = toConvert.indexOf(Converter.TIME_SEPARATOR);
            String h = toConvert.substring(0, pos);
            String m = toConvert.substring(pos + 1);
            BigDecimal t = new BigDecimal(m + ".00");
            t = t.divide(new BigDecimal("60.00"), BigDecimal.ROUND_HALF_UP);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.