How-to articles, tricks, and solutions about FORMATTING

Convert java.util.Date to String

To convert a java.util.Date object to a String, you can use the format method of the SimpleDateFormat class from the java.text package. The SimpleDateFormat class provides a convenient way to convert a Date object to a String based on a specified format.

Double decimal formatting in Java

To format a double value as a decimal in Java, you can use the DecimalFormat class from the java.text package. Here's an example of how to use it:

How can I pad an integer with zeros on the left?

To pad an integer with zeros on the left in Java, you can use the String.format() method and specify a minimum field width for the integer. For example:

How to change date format in a Java string?

To change the date format in a Java string, you can use the SimpleDateFormat class.

How to Format a Number with Two Decimals in JavaScript

Read this JavaScript tutorial and learn useful information about several easy built-in methods that are used for formatting the number with two decimals.

How to Format Number with Two Decimals

In this JavaScript tutorial, you will find information about the formatting number to display with two decimals. Also, read about solving rounding issues.

How to get AM/PM from a datetime in PHP

To get the AM/PM value for a given date and time in PHP, you can use the date() function with the a format string.

How to prettyprint a JSON file?

To pretty-print a JSON file in Python, you can use the json module.

How to Print a Circular Structure in a JSON-like Format

In this JavaScript tutorial, you will find useful information about the method that is used to format an object to JSON what contains circular structure.

How to print a float with 2 decimal places in Java?

To print a float with 2 decimal places in Java, you can use the printf method and specify a format string with the %.2f format specifier. Here's an example: