Author: saqibkhan

  • Locale specific Formatting Date

    Locale can be used to create locale specific formatting over a pattern in SimpleDateFormat class. See the following example of using locale specific SimpleDateFormat class. Example Open Compiler Output It will print the following result.

  • SimpleDateFormat Class

    java.text.SimpleDateFormat class formats dates as per the given pattern. It is also used to parse dates from string where string contains date in mentioned format. See the following example of using SimpleDateFormat class. Example Open Compiler Output It will print the following result.

  • Formatting Date and Time

    DateFormat class provides various formats to format the date and time together. DateFormat.getDateTimeInstance() method is to be used. See the example below. Example In following example we’ll show how to use different formats to format date and time. Open Compiler Output It will print the following result.

  • Formatting Time

    DateFormat class provides various formats to format the time. DateFormat.getTimeInstance() method is to be used. See the example below. Example In following example we’ll show how to use different formats to format time. Open Compiler Output It will print the following result.

  • Formatting Date

    DateFormat class provides various formats to format the date. Following is list of some of the formats. Example In following example we’ll show how to use different formats. Open Compiler Output It will print the following result.

  • DateFormat Class

    java.text.DateFormat class formats dates as per the locale. As different coutries use different formats to display dates. This class is extremely useful in dealing with dates in Internationalization of application. Following example show how to create and use DateFormat Class. Example Open Compiler Output It will print the following result.

  • Grouping Digits

    Using setGroupingSize() method of DecimalFormat, default grouping of numbers can be changed. Following example is illustrating the same. Example Open Compiler Output It will print the following result.

  • DecimalFormatSymbols Class

    Using DecimalFormatSymbols class, the default separator symbols, grouping separator symbols etc. can be changed. Following example is illustrating the same. Example Open Compiler Output It will print the following result.

  • Locale Specific DecimalFormat

    By default, DecimalFormat object is using the JVM’s locale. We can change the default locale while creating the DecimalFormat object using NumberFormat class. In the example below, we’ll use same pattern for two different locale and you can spot the difference in the output. Example Open Compiler Output It will print the following result.

  • Formatting Patterns

    Followings is the use of characters in formatting patterns. Sr.No. Class & Description 1 0To display 0 if less digits are present. 2 #To display digit ommitting leading zeroes. 3 .Decimal separator. 4 ,Grouping separator. 5 EMantissa and Exponent separator for exponential formats. 6 ;Format separator. 7 –Negative number prefix. 8 %Shows number as percentage…