Welcome to Kode Java
Kode Java website provides beginners to Java programming some examples to use the Java API (Application Programming Interface) to develop applications. Learning from some examples will hopefully decrease the time required to learn Java.
In this website you will find a lot of examples which grouped by the Java API package. You can easily find a solution to your problem. To help you learn more we have also setup a discussion forums where everyone can share their Java knowledge.
Enjoy your study, come and visit the site regularly to find more and more examples of Java code. If you have a feedback or question related to the website you can drop an email .
--Kode Java Webmaster
Latest Code Examples
How do I convert day of the year to date?
package org.kodejava.example.util; import java.util.Calendar; public class DayOfYearToDate { public static void main(String[] args) { // // In the example we want to get the date value of the specified day of // the year. Using the calendar object we can define our calendar for // a specific day of the year. // int dayOfYear = 112; Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_YEAR, dayOfYear); System.out.println("Day of year " + dayOfYear + " = " + calendar.getTime()); // // If you want to get the date for a specific day of year and for a // specific year, you can also pass the year information to the calendar // object. // int year = 2004; calendar.set(Calendar.YEAR, year); System.out.println("Day of year " + dayOfYear + " in year " + year + " = " + calendar.getTime()); } } |
And here is an example result of the code above:
Day of year 112 = Sun Apr 22 16:53:03 GMT+07:00 2007 Day of year 112 in year 2004 = Wed Apr 21 16:53:03 GMT+07:00 2004
|
|