Samual Sam has Published 2492 Articles

Java Program to list Weekday names

Samual Sam

Samual Sam

Updated on 27-Jun-2020 14:46:33

2K+ Views

To list weekday names, use the getWeekdays () from the DateFormatSymbols class in Java.DateFormatSymbols is a class for encapsulating localizable date-time formatting data.Get weekday month names in an array −String[] days = new DateFormatSymbols().getWeekdays ();Display the weekdays −for (int i = 0; i < days.length; i++) {    String weekday ... Read More

Java Program to subtract 1 year from the calendar

Samual Sam

Samual Sam

Updated on 27-Jun-2020 13:53:38

1K+ Views

Firstly, you need to import the following package for Calendar class in Javaimport java.util.Calendar;Create a Calendar object and display the current date and timeCalendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us subtract 1 year using the calendar.add() method and Calendar.YEAR constant. Set a negative ... Read More

Java Program to add 3 months to the calendar

Samual Sam

Samual Sam

Updated on 27-Jun-2020 13:49:52

641 Views

Firstly, you need to import the following package for Calendar class in Javaimport java.util.Calendar;Create a Calendar object and display the current date and timeCalendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us add 3 months using the calendar.add() method and Calendar.MONTH constant −calendar.add(Calendar.MONTH, 3);The following ... Read More

Java Program to add days to current date using Java Calendar

Samual Sam

Samual Sam

Updated on 27-Jun-2020 13:39:54

773 Views

Import the following package for Calendar class in Javaimport java.util.Calendar;Firstly, create a Calendar object and display the current dateCalendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime());Now, let us add days using the add() method and Calendar.DATE constantcalendar.add(Calendar.DATE, 2);The following is an exampleExample Live Demoimport java.util.Calendar; public class Demo { ... Read More

Add week to current date using Calendar.add() method in Java

Samual Sam

Samual Sam

Updated on 27-Jun-2020 13:34:17

1K+ Views

Import the following package for Calendar class in Javaimport java.util.Calendar;Firstly, create a Calendar object and display the current date and timeCalendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us increment the weeks using the calendar.add() method and Calendar.WEEK_OF_YEAR constant.calendar.add(Calendar.WEEK_OF_YEAR, 2);The following is an exampleExample Live Demoimport ... Read More

Java Program to subtract year from current date

Samual Sam

Samual Sam

Updated on 27-Jun-2020 13:32:01

1K+ Views

Firstly, you need to import the following package for Calendar class in Javaimport java.util.Calendar;Create a Calendar object and display the current date and timeCalendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us decrement the year using the calendar.add() method and Calendar.YEAR constant. Set a negative ... Read More

When is the !important rule used in CSS?

Samual Sam

Samual Sam

Updated on 27-Jun-2020 13:29:43

51 Views

The !important rule provides a way to make your CSS cascade. It also includes the rules that are to be applied always. A rule having a !important property will always be applied, no matter where that rule appears in the CSS document.ExampleFor example, in the following style sheet, the paragraph ... Read More

Java Program to format Month in MMMM format

Samual Sam

Samual Sam

Updated on 27-Jun-2020 13:29:42

231 Views

Set the month format as MMMM, while including the date-time format in SimpleDateFormat object.Firstly, set the date objectDate dt = new Date();Now, set the format for date-timeSimpleDateFormat dateFormat = new SimpleDateFormat("EEEE MMMM dd yyyy kk:mm:ss");Display the date with the format you wantdateFormat.format(dt)The following is an exampleExample Live Demoimport java.text.SimpleDateFormat; import java.util.Date; ... Read More

Increment a Date using the Java Calendar Class

Samual Sam

Samual Sam

Updated on 27-Jun-2020 13:26:13

231 Views

Import the following package for Calendar class in Javaimport java.util.Calendar;Firstly, create a Calendar object and display the current dateCalendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime());Now, let us increment the date using the add() method and Calendar.DATE constantcalendar.add(Calendar.DATE, 2);The following is the complete exampleExample Live Demoimport java.util.Calendar; public class ... Read More

Increment a Month using the Calendar Class in Java

Samual Sam

Samual Sam

Updated on 27-Jun-2020 13:24:02

396 Views

Import the following package for Calendar class in Javaimport java.util.Calendar;Firstly, create a Calendar object and display the current dateCalendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime());Now, let us increment the month using the add() method and Calendar.MONTH constant −calendar.add(Calendar.MONTH, 2);The following is an exampleExample Live Demoimport java.util.Calendar; public class ... Read More

Advertisements