This Java program calculates the date that is two weeks after the current date. Here is a breakdown of the code:
Note that the java.util.Calendar class is an older way of working with dates and times in Java. Starting from Java 8, it is recommended to use the java.time package, which provides a more modern and comprehensive set of classes for working with dates and times.
import java.util.*; public class DateAfter_TwoWeeks { public static void main(String[] args) { int nod = 14; Calendar cal = Calendar.getInstance(); Date cd = cal.getTime(); cal.add(Calendar.DAY_OF_YEAR, nod); Date d = cal.getTime(); System.out.println("Current Date : " + cd); System.out.println("Day After Two Weeks : " + d); } }
Current Date : Sat Nov 05 13:43:27 IST 2022 Day After Two Weeks : Sat Nov 19 13:43:27 IST 2022
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions