Questions tagged [formatter]

A formatter may be any program or piece of program that modifies a file or input text so that it complies to a given format, or generate a text in a given format from input data. Examples include: formatting a date to a localized format; indent a source code; replace variables in a string with inputted values; etc.

A formatter may be any program or piece of program that modifies a file or input text so that it complies to a given format, or generate a text in a given format from input data. Examples include: formatting a date to a localized format; indent a source code; replace variables in a string with inputted values; etc.

743 questions
108
votes
6 answers

How to stop Eclipse formatter from placing all enums on one line

I have enums like: public static enum Command { login, register, logout, newMessage } When formatting the file, the output becomes: public static enum Command { login, register, logout, newMessage }
MetaChrome
  • 3,042
  • 6
  • 25
  • 48
86
votes
4 answers

Understanding the $ in Java's format strings

StringBuilder sb = new StringBuilder(); // Send all output to the Appendable object sb Formatter formatter = new Formatter(sb, Locale.US); // Explicit argument indices may be used to re-order output. formatter.format("%4$2s %3$2s %2$2s %1$2s",…
andandandand
  • 20,448
  • 55
  • 163
  • 248
79
votes
7 answers

How can I correctly format currency using jquery?

I do not need a mask, but I need something that will format currency(in all browsers) and not allow for any letters or special char's to be typed. Thanks for the help Example: Valid: $50.00 $1,000.53 Not Valid: $w45.00 $34.3r6
ninjasense
  • 13,382
  • 17
  • 71
  • 91
79
votes
11 answers

Making Eclipse's Java code formatter ignore block comments

Is there a way to make Eclipse's built-in Java code formatter ignore comments? Whenever I run it, it turns this: /* * PSEUDOCODE * Read in user's string/paragraph * * Three cases are possible * Case 1: foobar * …
Pops
  • 28,257
  • 34
  • 127
  • 149
55
votes
10 answers

datetime: Round/trim number of digits in microseconds

Currently I am logging stuff and I am using my own formatter with a custom formatTime(): def formatTime(self, _record, _datefmt): t = datetime.datetime.now() return t.strftime('%Y-%m-%d %H:%M:%S.%f') My issue is that the microseconds, %f,…
Parham
  • 2,217
  • 3
  • 21
  • 39
52
votes
5 answers

Double parameter with 2 digits after dot in strings.xml?

I want to have a parameter in one string in strings.xml and this parameter should be a double value. So I use %1$f. Here - http://developer.android.com/reference/java/util/Formatter.html there are many examples, but what if I want to have have a few…
lomza
  • 8,576
  • 13
  • 63
  • 82
46
votes
0 answers

Recommendations for a JSON editor on Windows?

Are there any JSON editors on Windows? I tried Notepad++, but it only supports JSON with third party plug-ins which need to be called from Notepad++'s menus each time you open a JSON file. And some of them do not work properly. I tried Gedit for…
Ali Kaptan
  • 469
  • 1
  • 4
  • 3
36
votes
10 answers

Android NumberPicker with Formatter doesn't format on first rendering

I have a NumberPicker that has a formatter that formats the displayed numbers either when the NumberPicker spins or when a value is entered manually. This works fine, but when the NumberPicker is first shown and I initialize it with setValue(0) the…
A. Steenbergen
  • 3,180
  • 3
  • 31
  • 48
36
votes
8 answers

How to properly format currency on ios

I'm looking for a way to format a string into currency without using the TextField hack. For example, i'd like to have the number "521242" converted into "5,212.42" Or if I have a number under 1$, I would like it to look like this: "52" ->…
François Marceau
  • 582
  • 1
  • 4
  • 10
28
votes
6 answers

Python Formatter Tool

I was wondering if there exists a sort of Python beautifier like the gnu-indent command line tool for C code. Of course indentation is not the point in Python since it is programmer's responsibility but I wish to get my code written in a perfectly…
user127555
  • 381
  • 1
  • 3
  • 8
27
votes
1 answer

Java string align to right

I have an array of these numbers 61672 8414449 264957 I use a DecimalFormat object like this DecimalFormat formatter = new DecimalFormat("###,### bytes"); to get these results 61,672 bytes 8,414,449 bytes 264,957 bytes but I need the results to…
David Weng
  • 3,985
  • 12
  • 38
  • 49
24
votes
2 answers

Regular expression does not match newline obtained from Formatter object

I cannot match a String containing newlines when the newline is obtained by using %n in Formatter object or String.format(). Please have a look at the following program: public class RegExTest { public static void main(String[] args) { String…
Axel
  • 13,204
  • 4
  • 44
  • 72
24
votes
1 answer

Change how eclipse formatter wraps long strings

I have set the eclipse java formatter to wrap lines that exceed 120 characters to conform to our team's coding standard. However, when I have a long string that is wrapped I want the plus sign (+) to appear as the last character on the first line…
Mathias Åhsberg
  • 367
  • 1
  • 3
  • 13
23
votes
3 answers

How can I get eclipse to wrap lines after a period instead of before

I've looked throughout Preferences -> Java -> Code Style -> Formatter and can't find any way to get eclipse to format my code like: something. someMethod(). anotherMethod(). lastMethod(); Instead of: something .someMethod() …
onlynone
  • 6,408
  • 3
  • 28
  • 44
19
votes
3 answers

Can the Eclipse Java formatter be used stand-alone

Is there a way to use the formatter that comes with eclipse, outside of eclipse? I would like to format some java files using my formatter.xml file that I have configured using eclipse. Does anyone have any code examples that would allow me to do…
Milhous
  • 14,003
  • 16
  • 60
  • 80
1
2 3
49 50