- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9316 Articles for Object Oriented Programming
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
444 Views
Argument indices allow programmers to reorder the output. Let us see an example.Example Live Demopublic class Demo { public static void main(String[] args) { System.out.printf("Before reordering = %s %s %s %s %s %s", "one", "two", "three", "four", "five", "six" ); System.out.printf("After reordering = %6$s %5$s %4$s %3$s %2$s %1$s", "one", "two", "three", "four", "five", "six" ); System.out.printf("Before reordering = %d %d %d", 100, 200, 300); System.out.printf("After reordering = %2$d %3$d %1$d", 100, 200, 300); } }OutputBefore reordering = one two three four five six After reordering = ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
84 Views
To display localized method name in Java, use the ‘B’ conversion character.System.out.printf("Localized month : %TB", d);To display method name in lowercase, use the “%tb”System.out.printf("Localized month : %tB", d);Example Live Demoimport java.util.Date; public class Demo { public static void main(String[] args) { Date d = new Date(); System.out.printf("Morning/afternoon indicator: %tp", d); System.out.printf("Morning/afternoon indicator: %Tp", d); System.out.printf("Localized month : %tB", d); System.out.printf("Localized month : %TB", d); } }OutputMorning/afternoon indicator: pm Morning/afternoon indicator: PM Localized month : November Localized month : NOVEMBERRight justify and left justify values ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
68 Views
Locale-specific morning/afternoon indicator is the AM/PM marker indicator.Use the ‘p’ conversion character to display AM/PM.System.out.printf("Morning/afternoon indicator: %tp",d);Example Live Demoimport java.util.Date; public class Demo { public static void main(String[] args) { Date d = new Date(); System.out.printf("Morning/afternoon indicator: %tp",d); System.out.printf("Morning/afternoon indicator: %Tp",d); } }OutputMorning/afternoon indicator: pm Morning/afternoon indicator: PM
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
121 Views
To display milliseconds since the epoch, use the ‘Q’ Date and Time conversion specifier.System.out.printf("Milliseconds since epoch = %TQ", d);The above would display milliseconds since.1970-01-01 00:00:00 GMTExample Live Demoimport java.util.Date; public class Demo { public static void main(String[] args) { Date d = new Date(); System.out.printf("Nanoseconds = %tN", d); System.out.printf("Seconds since epoch = %ts", d); System.out.printf("Milliseconds since epoch = %TQ", d); } }OutputNanoseconds = 050000000 Seconds since epoch = 1543241478 Milliseconds since epoch = 1543241478050
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
347 Views
To display seconds since the epoch, use the ‘s’ Date and Time conversion specifier.System.out.printf("Seconds since epoch = %ts", d);The above would display seconds since.1970-01-01 00:00:00 GMTExample Live Demoimport java.util.Date; public class Demo { public static void main(String[] args) { Date d = new Date(); System.out.printf("Nanoseconds = %tN", d); System.out.printf("Seconds since epoch = %ts", d); } }OutputNanoseconds = 364000000 Seconds since epoch = 1543241402
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
779 Views
To display nanoseconds, use the ‘N’ Date and Time conversion specifier.System.out.printf("Nanoseconds = %tN", d);Example Live Demoimport java.util.Date; public class Demo { public static void main(String[] args) { Date d = new Date(); System.out.printf("Nanoseconds = %tN", d); } }OutputNanoseconds = 092000000
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
4K+ Views
To display number with thousands separator, set a comma flag.System.out.printf( "%,d",78567);The above would result.78, 567Let’s check for bigger numbers.System.out.printf( "%,d", 463758);The above would result.463,758Example Live Demopublic class Demo { public static void main( String args[] ) { System.out.printf( "%,d", 95647 ); System.out.printf( "%,d", 687467 ); System.out.printf( "%,.2f", 7546.21 ); System.out.printf( "%,.2f", 463758.787 ); System.out.printf( "%,.2f", 123456.5 ); } }Output95,647 687,467 7,546.21 463,758.79 123,456.50
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
123 Views
The following are the conversion characters for date-time −CharacterDescriptioncComplete date and timeFISO 8601 dateDU.S. formatted date (month/day/year)T24-hour timer12-hour timeR24-hour time, no secondsYFour-digit year (with leading zeroes)yLast two digits of the year (with leading zeroes)CFirst two digits of the year (with leading zeroes)BFull month namebAbbreviated month namemTwo-digit month (with leading zeroes)dTwo-digit day (with leading zeroes)eTwo-digit day (without leading zeroes)AFull weekday nameaAbbreviated weekday namejThree-digit day of year (with leading zeroes)HTwo-digit hour (with leading zeroes), between 00 and 23kTwo-digit hour (without leading zeroes), between 0 and 23ITwo-digit hour (with leading zeroes), between 01 and 12lTwo-digit hour (without leading zeroes), between 1 and 12MTwo-digit ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
278 Views
Floating-point conversion characters include the following.CharacterDescription%edecimal number in computerized scientific notation%Edecimal number in computerized scientific notation%fdecimal number%gbased on computerized scientific notation or decimal format, %Gbased on computerized scientific notation or decimal format, Example Live Demopublic class Demo { public static void main(String[] args) throws Exception { System.out.printf("Integer conversions..."); System.out.printf( "Integer: %d", 889 ); System.out.printf( "Negative Integer: %d", -78 ); System.out.printf( "Octal: %o", 677 ); System.out.printf( "Hexadecimal: %x", 56 ); System.out.printf( "Hexadecimal: %X", 99 ); System.out.printf("Floating-point conversions..."); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
108 Views
Intergral conversion characters include the following.CharacterDescription%dInteger%oOctal%xHexadecimal%XHexadecimalExample Live Demopublic class Demo { public static void main(String[] args) throws Exception { System.out.printf( "Integer: %d", 889 ); System.out.printf( "Negative Integer: %d", -78 ); System.out.printf( "Octal: %o", 677 ); System.out.printf( "Hexadecimal: %x", 56 ); System.out.printf( "Hexadecimal: %X", 99 ); } }OutputInteger: 889 Negative Integer: -78 Octal: 1245 Hexadecimal: 38 Hexadecimal: 63