formatting

Are there cultures in which the decimal separator is longer than one character?

邮差的信 提交于 2019-12-11 07:55:23
问题 I must write a stringToNumber parsing function that can use custom strings for the following: decimal separator ( . for en-US => 3.1415 ) thousands separator ( , for en-US => 1,000,000 ) positive sign ( + for en-US => +5 ) negative sign ( - for en-US => -5 ) Can I assume that these are only one character (which would make the implementation easier) or are there any cultures in which any of these are longer? 来源: https://stackoverflow.com/questions/46538917/are-there-cultures-in-which-the

Specify default format for Decimal.ToString() method

人盡茶涼 提交于 2019-12-11 07:43:26
问题 I have an application with a lot of calls to Decimal.ToString(void). The default format is not what is needed. I could change these calls to one of the other Decimal.ToString overloads, but it would be nicer if I didn't have to. So, is there a way to specify a different format for the Decimal.ToString(void) method so that I don't have to modify any of the calls to this method? Update As the answer below indicates, it is possible to do what I want, but I should not do so as it is not good

How do I make my side column extend all the way to the end?

こ雲淡風輕ζ 提交于 2019-12-11 07:36:17
问题 For my website, I can't get my side column to extend all the way to the end of the body column without giving it a fixed max height (it's supposed to adjust according to the length of the body, which is altered either by the amount of words/content the body has and/or the wrapping of the body in a smaller screen). Please keep in mind that I have a footer at the bottom that is supposed to take up the entire width of the screen so I can't do something that makes the side column longer than

How to format text of TextField? JavaFX

梦想的初衷 提交于 2019-12-11 06:57:26
问题 For example, if I enter 32164578542324236.97325074, this number should be displayed in a TextField like 32,164,578,542,324,236.97325074. I tried to handle this, but unsuccessfully: inputField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { BigDecimal bd = new BigDecimal(newValue); NumberFormat formatter = NumberFormat.getNumberInstance(); inputField.setText(formatter

Read Text File and Keep Formatting

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 06:54:05
问题 I am attempting to read a file and set the text of a richTextBox equal to it, but the formatting is disappearing after I do so. The "ENTER"s within the text file itself are not visible in the richTextBox. Here is the code I am using: try { using (StreamReader sr = new StreamReader(directory + filePath)) { while (!sr.EndOfStream) { initialText += sr.ReadLine(); } } } Any help would be greatly appreciated. 回答1: When you use sr.ReadLine() , carriage return is removed from string (because it's

Is there a non-klunky way to perform special-case formatting with bound data?

淺唱寂寞╮ 提交于 2019-12-11 06:51:13
问题 I am binding many controls on my form to an object returned from a method call like so: textBoxMoonBeam.DataBindings.Add(new Binding("Text", pi, "MoonBeam")); Note: "pi" is the name of an instantiation of the PlatypusInfo class. ...but when I am grabbing a dateTime value, which by definition includes the time appended to the date, but I only want to show the date in the control, I've got to eschew the type of binding above and instead do this: textBoxDateAztecsFirstSawElvis.Text = pi

Aligning with string formatting

♀尐吖头ヾ 提交于 2019-12-11 06:44:30
问题 I wish to achieve this sort of output with string formatting: GBP......0.8639......0.8399 I have tried using the following code (i stands for currency and e[0] and e[1] are buy and sell values): "{i:.<10}{e[0]:.^6}{e[1]:.>6}".format(i=i, e=e) but the above code does not align the second number to the right, but it just adds it behind the first number, like this: GBP.......0.86390.8399 How can I correct this? 回答1: As a generalized solution: Use this format string if you want the right column,

How to center a text using printf with `^` flag in Java?

主宰稳场 提交于 2019-12-11 06:42:28
问题 I know I can do it as follows: String s = "Hello"; int maxLength = 10; System.out.print(getSpaces((maxLength - s.length()) / 2) + s + getSpaces((maxLength - s.length()) / 2)); But I need to do it in a simple way. According to this page: Printf for Java Specification 3.0 (Section 9. flags): I can center the text using ^ as a flag with printf() like this: String s = "Hello"; int maxLength = 10; System.out.printf("%^" + maxLength + "s", s); But I got this error: Exception in thread "main" java

How to automatically format drools files with Eclipse?

孤者浪人 提交于 2019-12-11 06:26:13
问题 For our current project we have code formatting rules for java and xml files. Is there some way to configure Eclipse to format drools files (*.drl)? 回答1: As far as I know you can't. The current plugin doesn't format the DRL files. It can be a very good contribution to the project :) Cheers 来源: https://stackoverflow.com/questions/7723078/how-to-automatically-format-drools-files-with-eclipse

Populate DataGridView Column With a Double forcing to 2 Decimal Places, with Sort

Deadly 提交于 2019-12-11 05:53:36
问题 Sorry for the weird title but I didn't know how to phrase it any better. I'm trying to populate a column on my DataGridView with a number that has 2 decimal places. To do this I'm using Dim _Size as Double = 1.2345 DataGridView1.Item(0, 0).Value = Format(_Size, "0.00") This populates the data correctly, but when sorting by this column, it treats the item as a string. I found on the net, that if you convert the data being entered to a number type (double, integer etc..), it will then sort it