 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display three-digit day of the year in Java
Use the ‘j’ date conversion character to display three-digit day of the year.
System.out.printf("Three-digit Day of the Year: %tj/%Tj\n", d, d); Above, d is a date object −
Date d = new Date();
The following is an example −
Example
import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Demo {    public static void main(String[] args) throws Exception {       Date d = new Date();       DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a");       String format = dateFormat.format(d);       System.out.println("Current date and time = " + format);       System.out.printf("Four-digit Year = %TY\n",d);       System.out.printf("Two-digit Year = %ty\n",d);       System.out.printf("Three-digit Day of the Year: %tj/%Tj\n", d, d);    } }  Output
Current date and time = 26/11/2018 12:13:14 PM Four-digit Year = 2018 Two-digit Year = 18 Three-digit Day of the Year: 330/330
Advertisements
 