Questions tagged [format]

It may refer to text formatting, content format, file format, document file format, etc.

Format may refer to:

* Text formatting, typesetting of text elements

Computing:

* File format, particular way that information is encoded for storage in a computer file
* Content format, encoded format for converting a specific type of data to displayable information
* Document file format, for storing documents on a storage media, especially for use by computers
* Audio format, medium for storing sound and music
* Audio file format, for storing digital audio data on a computer system
* Format (command), a command-line utility in many computer operating systems
* Format (computing), a computer command to prepare hard disks
* Format (Common Lisp), a programming function

Source: Wikipedia

11241 questions
3275
votes
57 answers

How can I pretty-print JSON in a shell script?

Is there a (Unix) shell script to format JSON in human-readable form? Basically, I want it to transform the following: { "foo": "lorem", "bar": "ipsum" } ... into something like this: { "foo": "lorem", "bar": "ipsum" }
AnC
1817
votes
20 answers

How can I print literal curly-brace characters in a string and also use .format on it?

x = " \{ Hello \} {0} " print(x.format(42)) gives me : Key Error: Hello\\ I want to print the output: {Hello} 42
Schitti
  • 19,309
  • 6
  • 21
  • 21
911
votes
22 answers

.NET String.Format() to add commas in thousands place for a number

I want to add a comma in the thousands place for a number. String.Format()?
Seibar
  • 63,705
  • 37
  • 85
  • 98
711
votes
17 answers

How do I display a decimal value to 2 decimal places?

When displaying the value of a decimal currently with .ToString(), it's accurate to like 15 decimal places, and since I'm using it to represent dollars and cents, I only want the output to be 2 decimal places. Do I use a variation of .ToString()…
wows
  • 9,477
  • 6
  • 24
  • 27
657
votes
12 answers

Formatting a number with leading zeros in PHP

I have a variable which contains the value 1234567. I would like it to contain exactly 8 digits, i.e. 01234567. Is there a PHP function for that?
Andromeda
  • 11,531
  • 18
  • 68
  • 98
542
votes
27 answers

How to nicely format floating numbers to string without unnecessary decimal 0's

A 64-bit double can represent integer +/- 253 exactly. Given this fact, I choose to use a double type as a single type for all my types, since my largest integer is an unsigned 32-bit number. But now I have to print these pseudo integers, but the…
Pyrolistical
  • 26,088
  • 21
  • 78
  • 104
493
votes
9 answers

What is this date format? 2011-08-12T20:17:46.384Z

I have the following date: 2011-08-12T20:17:46.384Z. What format is this? I'm trying to parse it with Java 1.4 via DateFormat.getDateInstance().parse(dateStr) and I'm getting java.text.ParseException: Unparseable date:…
Sarah Vessels
  • 27,994
  • 29
  • 147
  • 217
431
votes
13 answers

How to auto-format code in Eclipse?

How do you auto-format code in Eclipse?
HasanAboShally
  • 17,553
  • 7
  • 26
  • 33
427
votes
29 answers

Android TextView Justify Text

How do you get the text of a TextView to be Justified (with text flush on the left- and right- hand sides)? I found a possible solution here, but it does not work (even if you change vertical-center to center_vertical, etc).
user130076
364
votes
26 answers

How do you display JavaScript datetime in 12 hour AM/PM format?

How do you display a JavaScript datetime object in the 12 hour format (AM/PM)?
bbrame
  • 15,041
  • 9
  • 33
  • 51
348
votes
16 answers

Convert one date format into another in PHP

Is there a simple way to convert one date format into another date format in PHP? I have this: $old_date = date('y-m-d-h-i-s'); // works $middle = strtotime($old_date); // returns bool(false) $new_date = date('Y-m-d H:i:s',…
Tom
  • 28,567
  • 26
  • 84
  • 120
337
votes
25 answers

How to format date and time in Android?

How to format correctly according to the device configuration date and time when having a year, month, day, hour and minute?
pupeno
  • 256,034
  • 114
  • 324
  • 541
336
votes
5 answers

What's the difference between ISO 8601 and RFC 3339 Date Formats?

ISO 8601 and RFC 3339 seem to be two formats that are common the web. Should I use one over the other? Is one just an extension? Do I really need to care that bad?
Brig Lamoreaux
327
votes
31 answers

Format timedelta to string

I'm having trouble formatting a datetime.timedelta object. Here's what I'm trying to do: I have a list of objects and one of the members of the class of the object is a timedelta object that shows the duration of an event. I would like to…
mawcs
  • 3,323
  • 2
  • 16
  • 7
322
votes
11 answers

How to use java.String.format in Scala?

I am trying to use a .format method of a string. But if I place %1, %2, etc. in the string, java.util.UnknownFormatConversionException is thrown pointing to a confusing Java source code piece: private void checkText(String s) { int idx; //…
Ivan
  • 59,167
  • 87
  • 235
  • 370
1
2 3
99 100