Tabnine Logo
Datatypes.getFormatStrings
Code IndexAdd Tabnine to your IDE (free)

How to use
getFormatStrings
method
in
com.haulmont.chile.core.datatypes.Datatypes

Best Java code snippets using com.haulmont.chile.core.datatypes.Datatypes.getFormatStrings (Showing top 8 results out of 315)

origin: com.haulmont.fts/fts-global

private Object tryDate(String value) {
  UserSessionSource userSession = AppBeans.get(UserSessionSource.NAME);
  FormatStrings formatStrings = Datatypes.getFormatStrings(userSession.getLocale());
  SimpleDateFormat sdf = new SimpleDateFormat(formatStrings.getDateFormat());
  try {
    Date date = sdf.parse(value);
    return date;
  } catch (ParseException e) {
    return null;
  }
}
origin: com.haulmont.fts/fts-global

  private Object tryNumber(String value) {
    UserSessionSource userSession = AppBeans.get(UserSessionSource.NAME);
    FormatStrings formatStrings = Datatypes.getFormatStrings(userSession.getLocale());
    char decimalSeparator = formatStrings.getFormatSymbols().getDecimalSeparator();
    char groupingSeparator = formatStrings.getFormatSymbols().getGroupingSeparator();
    if (decimalSeparator != '.')
      value = value.replace(decimalSeparator, '.');
    if (groupingSeparator != ',')
      value = value.replace(groupingSeparator, ',');

    if (!Character.isDigit(value.charAt(0)) || value.startsWith("0"))
      return null;

    try {
      Number number = new BigDecimal(value);
      return number;
    } catch (NumberFormatException e) {
      return null;
    }
  }
}
origin: com.haulmont.cuba/cuba-gui

  @Override
  public String apply(Number value) {
    if (value == null) {
      return null;
    }
    String pattern = element != null ? element.attributeValue("format") : null;

    if (pattern == null) {
      Datatype datatype = Datatypes.getNN(value.getClass());
      return datatype.format(value, userSessionSource.getLocale());
    } else {
      if (pattern.startsWith("msg://")) {
        pattern = messages.getMainMessage(pattern.substring(6, pattern.length()));
      }
      FormatStrings formatStrings = Datatypes.getFormatStrings(userSessionSource.getLocale());
      if (formatStrings == null)
        throw new IllegalStateException("FormatStrings are not defined for " + userSessionSource.getLocale());
      DecimalFormat format = new DecimalFormat(pattern, formatStrings.getFormatSymbols());
      return format.format(value);
    }
  }
}
origin: com.haulmont.cuba/cuba-gui

String type = element.attributeValue("type");
if (type != null) {
  FormatStrings formatStrings = Datatypes.getFormatStrings(userSessionSource.getLocale());
  if (formatStrings == null)
    throw new IllegalStateException("FormatStrings are not defined for " + userSessionSource.getLocale());
origin: com.haulmont.charts/charts-web

FormatStrings formatStrings = Datatypes.getFormatStrings(locale);
origin: com.haulmont.charts/charts-web

protected void setupFormatStrings(List<StockPanel> panels) {
  FormatStrings formatStrings = Datatypes.getFormatStrings(userSessionSource.getLocale());
  if (formatStrings != null) {
    for (StockPanel panel : panels) {
      DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols();
      if (panel.getPrecision() == null) {
        panel.setPrecision(-1);
      }
      if (panel.getPercentPrecision() == null) {
        panel.setPercentPrecision(2);
      }
      if (panel.getDecimalSeparator() == null) {
        panel.setDecimalSeparator(Character.toString(formatSymbols.getDecimalSeparator()));
      }
      if (panel.getThousandsSeparator() == null) {
        panel.setThousandsSeparator(Character.toString(formatSymbols.getGroupingSeparator()));
      }
    }
  }
}
origin: com.haulmont.charts/charts-web

protected void setupChartLocale(AbstractChart chart) {
  chart.setLanguage(messages.getTools().localeToString(userSessionSource.getLocale()));
  // number formatting
  FormatStrings formatStrings = Datatypes.getFormatStrings(userSessionSource.getLocale());
  if (formatStrings != null) {
    DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols();
    chart.setPrecision(-1);
    chart.setPercentPrecision(2);
    chart.setDecimalSeparator(Character.toString(formatSymbols.getDecimalSeparator()));
    chart.setThousandsSeparator(Character.toString(formatSymbols.getGroupingSeparator()));
  }
  // number prefixes
  List<BigNumberPrefix> bigPrefixes = new ArrayList<>();
  for (BigNumberPower power : BigNumberPower.values()) {
    bigPrefixes.add(new BigNumberPrefix(power,
        messages.getMainMessage("amcharts.bigNumberPower." + power.name())));
  }
  chart.setPrefixesOfBigNumbers(bigPrefixes);
  List<SmallNumberPrefix> smallPrefixes = new ArrayList<>();
  for (SmallNumberPower power : SmallNumberPower.values()) {
    smallPrefixes.add(new SmallNumberPrefix(power,
        messages.getMainMessage("amcharts.smallNumberPower." + power.name())));
  }
  chart.setPrefixesOfSmallNumbers(smallPrefixes);
}
origin: com.haulmont.charts/charts-web

FormatStrings formatStrings = Datatypes.getFormatStrings(userSessionSource.getLocale());
if (formatStrings != null) {
  DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols();
com.haulmont.chile.core.datatypesDatatypesgetFormatStrings

Javadoc

Returns localized format strings.

Popular methods of Datatypes

  • getNN
    Get Datatype instance by the corresponding Java class. This method tries to find matching supertype
  • get
    Get Datatype instance by its unique name
  • getIds
  • getDatatypeRegistry
  • getFormatStringsRegistry

Popular in Java

  • Updating database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • onRequestPermissionsResult (Fragment)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Kernel (java.awt.image)
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JOptionPane (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now