SlideShare a Scribd company logo
1 of 14
Download to read offline
publicclass Date {
privatestatic String DATE_SEPARATOR = "/";
privatestaticintDAYS_PER_WEEK = 7;
//Attributes
privateint day;
privateint month;
privateint year;
/**
* Default Constructor
* Instantiates an object of type Date to 1/1/2000
*/
public Date() {
this.day = 1;
this.month = 1;
this.year = 2000;
}
/**
* Constructs a new date object to represent the given date.
* @param day
* @param month
* @param year
*/
public Date(int day, int month, int year) {
if(isValid(day, month, year)) {
this.day = day;
this.month = month;
this.year = year;
} else
System.out.println("Invalid Date.");
}
/**
* Returns the day value of this date for example, for the date 2006/07/22, returns 22.
* @return
*/
publicint getDay() {
return day;
}
/**
* Returns the month value of this date ,for example, for the date 2006/07/22, returns 7.
* @return
*/
publicint getMonth() {
return month;
}
/**
* Returns the year value of this date, for example , the date 2006/07/22, returns 2006.
* @return
*/
publicint getYear() {
return year;
}
/**
* @param day the day to set
*/
publicvoid setDay(int day) {
this.day = day;
}
/**
* @param month the month to set
*/
publicvoid setMonth(int month) {
this.month = month;
}
/**
* @param year the year to set
*/
publicvoid setYear(int year) {
this.year = year;
}
/**
* Returns true if the year of this date is a leap year.
* A leap year occurs every 4 years , except for multiples of 100 that are not multiples of 400.
* For example, 1956,1844,1600,and 2000 are leap years, but 1983,2002,1700,and 1900 are not.
* @return
*/
publicboolean isLeapYear(){
if(((this.year % 400) == 0) || (((this.year % 4) == 0) && ((this.year % 100) != 0)))
returntrue;
else
returnfalse;
}
/**
* Checks if the date is valid
* @param day
* @param month
* @param year
* @return
*/
publicboolean isValid(int day, int month, int year) {
if((month < 1) || (12 < month))
returnfalse;
else {
if(((month == 1) || (month == 3) || (month == 5) || (month == 7) ||
(month == 8) || (month == 10) || (month == 12)) && ((day < 1) || (31 < day)))
returnfalse;
elseif(((month == 4) || (month == 6) || (month == 9) || (month == 11)) && ((day < 1) || (30 <
day)))
returnfalse;
elseif(month == 2) {
if(isLeapYear() && ((day < 1) || (29 < day)))
returnfalse;
elseif((day < 1) || (28 < day))
returnfalse;
}
}
returntrue;
}
/**
* Returns the maximum number of days in a month
* @return
*/
publicint maxMonthDays() {
if(this.month == 2) {
if(isLeapYear())
return 29;
else
return 28;
} elseif((this.month == 1) || (this.month == 3) || (this.month == 5) || (this.month == 7) ||
(this.month == 8) || (this.month == 10) || (this.month == 12))
return 31;
else
return 30;
}
/**
* Checks if this dat is same as other date
* @param other
* @return
*/
publicboolean isEqual(Date other) {
if((this.day == other.day) && (this.month == other.month) && (this.year == other.year))
returntrue;
else
returnfalse;
}
/**
* Moves this Date object forward in time by the given number of days .
* @param days
*/
publicvoid addDays(int days) {
while(days != 0){
int maxDays = maxMonthDays();
if((maxDays - this.day) >= days) {
this.day += days;
days = 0;
}
else{
days -= (maxDays - this.day);
this.day = 0;
if(month == 12) {
this.month = 1;
this.year += 1;
} else
this.month += 1;
}
}
}
/**
* Moves this date object forward in time by the given amount of seven day weeks
* @param weeks
*/
publicvoid addWeeks(int weeks) {
addDays(weeks * DAYS_PER_WEEK);
}
/**
* Returns the number of days that this Date must be adjusted to make it equal to the given other
Date.
* @param other
* @return
*/
publicint daysTo(Date other) {
Date temp = new Date(this.day, this.month, this.year);
if(temp.isEqual(other))
return 0;
else{
int noOfDays = 0;
do {
if((temp.year == other.year) && (temp.month == other.month)) {
noOfDays += (other.day - temp.day);
temp.day = other.day;
}
else{
int maxDays = temp.maxMonthDays();
noOfDays += (maxDays - temp.day);
temp.day = 0;
if(temp.month == 12) {
temp.month = 1;
temp.year += 1;
}
else
temp.month += 1;
}
} while(!temp.isEqual(other));
return noOfDays;
}
}
/**
* Returns a String representation of this date in year/month/day order, such as "2006/07/22"
*/
@Override
public String toString() {
returnthis.day + DATE_SEPARATOR + this.month + DATE_SEPARATOR + this.year;
}
}
publicclass Driver {
publicstaticvoid main(String[] args) {
Date d1 = new Date(29, 1, 2016);
Date d2 = new Date(29, 12, 2015);
//Add 5 days to d1
System.out.println(" Add 5 days to " + d1 + " : ");
d1.addDays(5);
System.out.println(d1);
//Add 5 days to d2
System.out.println(" Add 5 days to " + d2 + " : ");
d2.addDays(5);
System.out.println(d2);
Date d3 = new Date(28, 8, 2016);
//Add 1 week to d3
System.out.println(" Add 1 week to " + d3 + " : ");
d3.addWeeks(1);
System.out.println(d3);
Date d4 = new Date(31, 8, 2016);
Date d5 = new Date(1, 10, 2016);
System.out.println(" The number of days that " + d4 + " must be adjusted to make it equal to
" + d5 + " : " + d4.daysTo(d5) + " days.");
}
}
SAMPLE OUTPUT :
Add 5 days to 29/1/2016 :
3/2/2016
Add 5 days to 29/12/2015 :
3/1/2016
Add 1 week to 28/8/2016 :
4/9/2016
The number of days that 31/8/2016 must be adjusted to make it equal to 1/10/2016 : 31 days.
Solution
publicclass Date {
privatestatic String DATE_SEPARATOR = "/";
privatestaticintDAYS_PER_WEEK = 7;
//Attributes
privateint day;
privateint month;
privateint year;
/**
* Default Constructor
* Instantiates an object of type Date to 1/1/2000
*/
public Date() {
this.day = 1;
this.month = 1;
this.year = 2000;
}
/**
* Constructs a new date object to represent the given date.
* @param day
* @param month
* @param year
*/
public Date(int day, int month, int year) {
if(isValid(day, month, year)) {
this.day = day;
this.month = month;
this.year = year;
} else
System.out.println("Invalid Date.");
}
/**
* Returns the day value of this date for example, for the date 2006/07/22, returns 22.
* @return
*/
publicint getDay() {
return day;
}
/**
* Returns the month value of this date ,for example, for the date 2006/07/22, returns 7.
* @return
*/
publicint getMonth() {
return month;
}
/**
* Returns the year value of this date, for example , the date 2006/07/22, returns 2006.
* @return
*/
publicint getYear() {
return year;
}
/**
* @param day the day to set
*/
publicvoid setDay(int day) {
this.day = day;
}
/**
* @param month the month to set
*/
publicvoid setMonth(int month) {
this.month = month;
}
/**
* @param year the year to set
*/
publicvoid setYear(int year) {
this.year = year;
}
/**
* Returns true if the year of this date is a leap year.
* A leap year occurs every 4 years , except for multiples of 100 that are not multiples of 400.
* For example, 1956,1844,1600,and 2000 are leap years, but 1983,2002,1700,and 1900 are not.
* @return
*/
publicboolean isLeapYear(){
if(((this.year % 400) == 0) || (((this.year % 4) == 0) && ((this.year % 100) != 0)))
returntrue;
else
returnfalse;
}
/**
* Checks if the date is valid
* @param day
* @param month
* @param year
* @return
*/
publicboolean isValid(int day, int month, int year) {
if((month < 1) || (12 < month))
returnfalse;
else {
if(((month == 1) || (month == 3) || (month == 5) || (month == 7) ||
(month == 8) || (month == 10) || (month == 12)) && ((day < 1) || (31 < day)))
returnfalse;
elseif(((month == 4) || (month == 6) || (month == 9) || (month == 11)) && ((day < 1) || (30 <
day)))
returnfalse;
elseif(month == 2) {
if(isLeapYear() && ((day < 1) || (29 < day)))
returnfalse;
elseif((day < 1) || (28 < day))
returnfalse;
}
}
returntrue;
}
/**
* Returns the maximum number of days in a month
* @return
*/
publicint maxMonthDays() {
if(this.month == 2) {
if(isLeapYear())
return 29;
else
return 28;
} elseif((this.month == 1) || (this.month == 3) || (this.month == 5) || (this.month == 7) ||
(this.month == 8) || (this.month == 10) || (this.month == 12))
return 31;
else
return 30;
}
/**
* Checks if this dat is same as other date
* @param other
* @return
*/
publicboolean isEqual(Date other) {
if((this.day == other.day) && (this.month == other.month) && (this.year == other.year))
returntrue;
else
returnfalse;
}
/**
* Moves this Date object forward in time by the given number of days .
* @param days
*/
publicvoid addDays(int days) {
while(days != 0){
int maxDays = maxMonthDays();
if((maxDays - this.day) >= days) {
this.day += days;
days = 0;
}
else{
days -= (maxDays - this.day);
this.day = 0;
if(month == 12) {
this.month = 1;
this.year += 1;
} else
this.month += 1;
}
}
}
/**
* Moves this date object forward in time by the given amount of seven day weeks
* @param weeks
*/
publicvoid addWeeks(int weeks) {
addDays(weeks * DAYS_PER_WEEK);
}
/**
* Returns the number of days that this Date must be adjusted to make it equal to the given other
Date.
* @param other
* @return
*/
publicint daysTo(Date other) {
Date temp = new Date(this.day, this.month, this.year);
if(temp.isEqual(other))
return 0;
else{
int noOfDays = 0;
do {
if((temp.year == other.year) && (temp.month == other.month)) {
noOfDays += (other.day - temp.day);
temp.day = other.day;
}
else{
int maxDays = temp.maxMonthDays();
noOfDays += (maxDays - temp.day);
temp.day = 0;
if(temp.month == 12) {
temp.month = 1;
temp.year += 1;
}
else
temp.month += 1;
}
} while(!temp.isEqual(other));
return noOfDays;
}
}
/**
* Returns a String representation of this date in year/month/day order, such as "2006/07/22"
*/
@Override
public String toString() {
returnthis.day + DATE_SEPARATOR + this.month + DATE_SEPARATOR + this.year;
}
}
publicclass Driver {
publicstaticvoid main(String[] args) {
Date d1 = new Date(29, 1, 2016);
Date d2 = new Date(29, 12, 2015);
//Add 5 days to d1
System.out.println(" Add 5 days to " + d1 + " : ");
d1.addDays(5);
System.out.println(d1);
//Add 5 days to d2
System.out.println(" Add 5 days to " + d2 + " : ");
d2.addDays(5);
System.out.println(d2);
Date d3 = new Date(28, 8, 2016);
//Add 1 week to d3
System.out.println(" Add 1 week to " + d3 + " : ");
d3.addWeeks(1);
System.out.println(d3);
Date d4 = new Date(31, 8, 2016);
Date d5 = new Date(1, 10, 2016);
System.out.println(" The number of days that " + d4 + " must be adjusted to make it equal to
" + d5 + " : " + d4.daysTo(d5) + " days.");
}
}
SAMPLE OUTPUT :
Add 5 days to 29/1/2016 :
3/2/2016
Add 5 days to 29/12/2015 :
3/1/2016
Add 1 week to 28/8/2016 :
4/9/2016
The number of days that 31/8/2016 must be adjusted to make it equal to 1/10/2016 : 31 days.

More Related Content

Similar to publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf

Write a program to generate the entire calendar for one year. The pr.pdf
Write a program to generate the entire calendar for one year. The pr.pdfWrite a program to generate the entire calendar for one year. The pr.pdf
Write a program to generate the entire calendar for one year. The pr.pdfarihantmobileselepun
 
@author Haolin Jin To generate weather for locatio.pdf
 @author Haolin Jin To generate weather for locatio.pdf @author Haolin Jin To generate weather for locatio.pdf
@author Haolin Jin To generate weather for locatio.pdfchennaiallfoodwear
 
Assignment Details There is a .h file on Moodle that provides a defi.pdf
Assignment Details There is a .h file on Moodle that provides a defi.pdfAssignment Details There is a .h file on Moodle that provides a defi.pdf
Assignment Details There is a .h file on Moodle that provides a defi.pdfjyothimuppasani1
 
Date time function in Database
Date time function in DatabaseDate time function in Database
Date time function in DatabaseSarfaraz Ghanta
 
Please I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdfPlease I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdfankit11134
 
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docxQ2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docxamrit47
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfjaipur2
 
Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4Synapseindiappsdevelopment
 
Need to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdfNeed to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdfanjandavid
 
Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)Faysal Shaarani (MBA)
 
Dynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeDynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeMagnify Analytic Solutions
 
In this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docxIn this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docxjaggernaoma
 
DO NOT use System.exit().DO NOT add the project or package stateme.pdf
DO NOT use System.exit().DO NOT add the project or package stateme.pdfDO NOT use System.exit().DO NOT add the project or package stateme.pdf
DO NOT use System.exit().DO NOT add the project or package stateme.pdfinfo48697
 
Data20161007
Data20161007Data20161007
Data20161007capegmail
 
Date object.pptx date and object v
Date object.pptx date and object        vDate object.pptx date and object        v
Date object.pptx date and object v22x026
 

Similar to publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf (20)

Write a program to generate the entire calendar for one year. The pr.pdf
Write a program to generate the entire calendar for one year. The pr.pdfWrite a program to generate the entire calendar for one year. The pr.pdf
Write a program to generate the entire calendar for one year. The pr.pdf
 
ThreeTen
ThreeTenThreeTen
ThreeTen
 
@author Haolin Jin To generate weather for locatio.pdf
 @author Haolin Jin To generate weather for locatio.pdf @author Haolin Jin To generate weather for locatio.pdf
@author Haolin Jin To generate weather for locatio.pdf
 
Assignment Details There is a .h file on Moodle that provides a defi.pdf
Assignment Details There is a .h file on Moodle that provides a defi.pdfAssignment Details There is a .h file on Moodle that provides a defi.pdf
Assignment Details There is a .h file on Moodle that provides a defi.pdf
 
Script Files
Script FilesScript Files
Script Files
 
Date time function in Database
Date time function in DatabaseDate time function in Database
Date time function in Database
 
datetimefuction-170413055211.pptx
datetimefuction-170413055211.pptxdatetimefuction-170413055211.pptx
datetimefuction-170413055211.pptx
 
Please I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdfPlease I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdf
 
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docxQ2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdf
 
Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4
 
Need to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdfNeed to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdf
 
Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)
 
Dynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeDynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using Time
 
In this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docxIn this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docx
 
Functional C++
Functional C++Functional C++
Functional C++
 
DO NOT use System.exit().DO NOT add the project or package stateme.pdf
DO NOT use System.exit().DO NOT add the project or package stateme.pdfDO NOT use System.exit().DO NOT add the project or package stateme.pdf
DO NOT use System.exit().DO NOT add the project or package stateme.pdf
 
Jsr310
Jsr310Jsr310
Jsr310
 
Data20161007
Data20161007Data20161007
Data20161007
 
Date object.pptx date and object v
Date object.pptx date and object        vDate object.pptx date and object        v
Date object.pptx date and object v
 

More from mukhtaransarcloth

S monoclinic is most stable since entropy is the .pdf
                     S monoclinic is most stable since entropy is the .pdf                     S monoclinic is most stable since entropy is the .pdf
S monoclinic is most stable since entropy is the .pdfmukhtaransarcloth
 
Option D is correct. B is limiting reagent .pdf
                     Option D is correct.  B is limiting reagent      .pdf                     Option D is correct.  B is limiting reagent      .pdf
Option D is correct. B is limiting reagent .pdfmukhtaransarcloth
 
Let us assume the conc of Ba(OH)2 is known to us .pdf
                     Let us assume the conc of Ba(OH)2 is known to us .pdf                     Let us assume the conc of Ba(OH)2 is known to us .pdf
Let us assume the conc of Ba(OH)2 is known to us .pdfmukhtaransarcloth
 
london dispersion forces .pdf
                     london dispersion forces                         .pdf                     london dispersion forces                         .pdf
london dispersion forces .pdfmukhtaransarcloth
 
Methods a, b, c, and e are formal additions of H2.pdf
                     Methods a, b, c, and e are formal additions of H2.pdf                     Methods a, b, c, and e are formal additions of H2.pdf
Methods a, b, c, and e are formal additions of H2.pdfmukhtaransarcloth
 
h2s4 structure is H-S-S-S-S-H there for two middl.pdf
                     h2s4 structure is H-S-S-S-S-H there for two middl.pdf                     h2s4 structure is H-S-S-S-S-H there for two middl.pdf
h2s4 structure is H-S-S-S-S-H there for two middl.pdfmukhtaransarcloth
 
freezing point decreases with increase in imp.pdf
                     freezing point decreases   with  increase  in imp.pdf                     freezing point decreases   with  increase  in imp.pdf
freezing point decreases with increase in imp.pdfmukhtaransarcloth
 
We are currently living in the so-called information age which can b.pdf
We are currently living in the so-called information age which can b.pdfWe are currently living in the so-called information age which can b.pdf
We are currently living in the so-called information age which can b.pdfmukhtaransarcloth
 
The balanced equation is2 H2O2 = 2 H2O + O2SolutionThe bal.pdf
The balanced equation is2 H2O2 = 2 H2O + O2SolutionThe bal.pdfThe balanced equation is2 H2O2 = 2 H2O + O2SolutionThe bal.pdf
The balanced equation is2 H2O2 = 2 H2O + O2SolutionThe bal.pdfmukhtaransarcloth
 
Tay-Sachs disease is caused by a mutation (abnormal change) in the g.pdf
Tay-Sachs disease is caused by a mutation (abnormal change) in the g.pdfTay-Sachs disease is caused by a mutation (abnormal change) in the g.pdf
Tay-Sachs disease is caused by a mutation (abnormal change) in the g.pdfmukhtaransarcloth
 
E.) is less acidic in other A ,B triple bond an.pdf
                     E.) is less acidic   in other A ,B triple bond an.pdf                     E.) is less acidic   in other A ,B triple bond an.pdf
E.) is less acidic in other A ,B triple bond an.pdfmukhtaransarcloth
 
Solution when user sending the email, then user should select eithe.pdf
Solution when user sending the email, then user should select eithe.pdfSolution when user sending the email, then user should select eithe.pdf
Solution when user sending the email, then user should select eithe.pdfmukhtaransarcloth
 
please give me points as nobody ecen noticed the qusetion as it is u.pdf
please give me points as nobody ecen noticed the qusetion as it is u.pdfplease give me points as nobody ecen noticed the qusetion as it is u.pdf
please give me points as nobody ecen noticed the qusetion as it is u.pdfmukhtaransarcloth
 
Part-IQuestion 1. What is Dr. Warren’s hypothesis regarding the ba.pdf
Part-IQuestion 1. What is Dr. Warren’s hypothesis regarding the ba.pdfPart-IQuestion 1. What is Dr. Warren’s hypothesis regarding the ba.pdf
Part-IQuestion 1. What is Dr. Warren’s hypothesis regarding the ba.pdfmukhtaransarcloth
 
Peru is not a part of the Southern South America.SolutionPeru .pdf
Peru is not a part of the Southern South America.SolutionPeru .pdfPeru is not a part of the Southern South America.SolutionPeru .pdf
Peru is not a part of the Southern South America.SolutionPeru .pdfmukhtaransarcloth
 
Combustion of glucose is respiration. The equatio.pdf
                     Combustion of glucose is respiration. The equatio.pdf                     Combustion of glucose is respiration. The equatio.pdf
Combustion of glucose is respiration. The equatio.pdfmukhtaransarcloth
 
in truss one...the forces in the member BC and DE have zero.in tru.pdf
in truss one...the forces in the member BC and DE have zero.in tru.pdfin truss one...the forces in the member BC and DE have zero.in tru.pdf
in truss one...the forces in the member BC and DE have zero.in tru.pdfmukhtaransarcloth
 
iam giving you entire process of  forensc duplication;the response.pdf
iam giving you entire process of  forensc duplication;the response.pdfiam giving you entire process of  forensc duplication;the response.pdf
iam giving you entire process of  forensc duplication;the response.pdfmukhtaransarcloth
 
How does traffic analysis work Internet data packets have two parts.pdf
How does traffic analysis work Internet data packets have two parts.pdfHow does traffic analysis work Internet data packets have two parts.pdf
How does traffic analysis work Internet data packets have two parts.pdfmukhtaransarcloth
 

More from mukhtaransarcloth (20)

S monoclinic is most stable since entropy is the .pdf
                     S monoclinic is most stable since entropy is the .pdf                     S monoclinic is most stable since entropy is the .pdf
S monoclinic is most stable since entropy is the .pdf
 
Option D is correct. B is limiting reagent .pdf
                     Option D is correct.  B is limiting reagent      .pdf                     Option D is correct.  B is limiting reagent      .pdf
Option D is correct. B is limiting reagent .pdf
 
Let us assume the conc of Ba(OH)2 is known to us .pdf
                     Let us assume the conc of Ba(OH)2 is known to us .pdf                     Let us assume the conc of Ba(OH)2 is known to us .pdf
Let us assume the conc of Ba(OH)2 is known to us .pdf
 
london dispersion forces .pdf
                     london dispersion forces                         .pdf                     london dispersion forces                         .pdf
london dispersion forces .pdf
 
Methods a, b, c, and e are formal additions of H2.pdf
                     Methods a, b, c, and e are formal additions of H2.pdf                     Methods a, b, c, and e are formal additions of H2.pdf
Methods a, b, c, and e are formal additions of H2.pdf
 
h2s4 structure is H-S-S-S-S-H there for two middl.pdf
                     h2s4 structure is H-S-S-S-S-H there for two middl.pdf                     h2s4 structure is H-S-S-S-S-H there for two middl.pdf
h2s4 structure is H-S-S-S-S-H there for two middl.pdf
 
freezing point decreases with increase in imp.pdf
                     freezing point decreases   with  increase  in imp.pdf                     freezing point decreases   with  increase  in imp.pdf
freezing point decreases with increase in imp.pdf
 
We are currently living in the so-called information age which can b.pdf
We are currently living in the so-called information age which can b.pdfWe are currently living in the so-called information age which can b.pdf
We are currently living in the so-called information age which can b.pdf
 
The balanced equation is2 H2O2 = 2 H2O + O2SolutionThe bal.pdf
The balanced equation is2 H2O2 = 2 H2O + O2SolutionThe bal.pdfThe balanced equation is2 H2O2 = 2 H2O + O2SolutionThe bal.pdf
The balanced equation is2 H2O2 = 2 H2O + O2SolutionThe bal.pdf
 
Tay-Sachs disease is caused by a mutation (abnormal change) in the g.pdf
Tay-Sachs disease is caused by a mutation (abnormal change) in the g.pdfTay-Sachs disease is caused by a mutation (abnormal change) in the g.pdf
Tay-Sachs disease is caused by a mutation (abnormal change) in the g.pdf
 
E.) is less acidic in other A ,B triple bond an.pdf
                     E.) is less acidic   in other A ,B triple bond an.pdf                     E.) is less acidic   in other A ,B triple bond an.pdf
E.) is less acidic in other A ,B triple bond an.pdf
 
Solution when user sending the email, then user should select eithe.pdf
Solution when user sending the email, then user should select eithe.pdfSolution when user sending the email, then user should select eithe.pdf
Solution when user sending the email, then user should select eithe.pdf
 
please give me points as nobody ecen noticed the qusetion as it is u.pdf
please give me points as nobody ecen noticed the qusetion as it is u.pdfplease give me points as nobody ecen noticed the qusetion as it is u.pdf
please give me points as nobody ecen noticed the qusetion as it is u.pdf
 
covalent bond .pdf
                     covalent bond                                    .pdf                     covalent bond                                    .pdf
covalent bond .pdf
 
Part-IQuestion 1. What is Dr. Warren’s hypothesis regarding the ba.pdf
Part-IQuestion 1. What is Dr. Warren’s hypothesis regarding the ba.pdfPart-IQuestion 1. What is Dr. Warren’s hypothesis regarding the ba.pdf
Part-IQuestion 1. What is Dr. Warren’s hypothesis regarding the ba.pdf
 
Peru is not a part of the Southern South America.SolutionPeru .pdf
Peru is not a part of the Southern South America.SolutionPeru .pdfPeru is not a part of the Southern South America.SolutionPeru .pdf
Peru is not a part of the Southern South America.SolutionPeru .pdf
 
Combustion of glucose is respiration. The equatio.pdf
                     Combustion of glucose is respiration. The equatio.pdf                     Combustion of glucose is respiration. The equatio.pdf
Combustion of glucose is respiration. The equatio.pdf
 
in truss one...the forces in the member BC and DE have zero.in tru.pdf
in truss one...the forces in the member BC and DE have zero.in tru.pdfin truss one...the forces in the member BC and DE have zero.in tru.pdf
in truss one...the forces in the member BC and DE have zero.in tru.pdf
 
iam giving you entire process of  forensc duplication;the response.pdf
iam giving you entire process of  forensc duplication;the response.pdfiam giving you entire process of  forensc duplication;the response.pdf
iam giving you entire process of  forensc duplication;the response.pdf
 
How does traffic analysis work Internet data packets have two parts.pdf
How does traffic analysis work Internet data packets have two parts.pdfHow does traffic analysis work Internet data packets have two parts.pdf
How does traffic analysis work Internet data packets have two parts.pdf
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 

publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf

  • 1. publicclass Date { privatestatic String DATE_SEPARATOR = "/"; privatestaticintDAYS_PER_WEEK = 7; //Attributes privateint day; privateint month; privateint year; /** * Default Constructor * Instantiates an object of type Date to 1/1/2000 */ public Date() { this.day = 1; this.month = 1; this.year = 2000; } /** * Constructs a new date object to represent the given date. * @param day * @param month * @param year */ public Date(int day, int month, int year) { if(isValid(day, month, year)) { this.day = day; this.month = month; this.year = year; } else System.out.println("Invalid Date."); } /** * Returns the day value of this date for example, for the date 2006/07/22, returns 22. * @return */ publicint getDay() {
  • 2. return day; } /** * Returns the month value of this date ,for example, for the date 2006/07/22, returns 7. * @return */ publicint getMonth() { return month; } /** * Returns the year value of this date, for example , the date 2006/07/22, returns 2006. * @return */ publicint getYear() { return year; } /** * @param day the day to set */ publicvoid setDay(int day) { this.day = day; } /** * @param month the month to set */ publicvoid setMonth(int month) { this.month = month; } /** * @param year the year to set */ publicvoid setYear(int year) { this.year = year; } /** * Returns true if the year of this date is a leap year.
  • 3. * A leap year occurs every 4 years , except for multiples of 100 that are not multiples of 400. * For example, 1956,1844,1600,and 2000 are leap years, but 1983,2002,1700,and 1900 are not. * @return */ publicboolean isLeapYear(){ if(((this.year % 400) == 0) || (((this.year % 4) == 0) && ((this.year % 100) != 0))) returntrue; else returnfalse; } /** * Checks if the date is valid * @param day * @param month * @param year * @return */ publicboolean isValid(int day, int month, int year) { if((month < 1) || (12 < month)) returnfalse; else { if(((month == 1) || (month == 3) || (month == 5) || (month == 7) || (month == 8) || (month == 10) || (month == 12)) && ((day < 1) || (31 < day))) returnfalse; elseif(((month == 4) || (month == 6) || (month == 9) || (month == 11)) && ((day < 1) || (30 < day))) returnfalse; elseif(month == 2) { if(isLeapYear() && ((day < 1) || (29 < day))) returnfalse; elseif((day < 1) || (28 < day)) returnfalse; } } returntrue; }
  • 4. /** * Returns the maximum number of days in a month * @return */ publicint maxMonthDays() { if(this.month == 2) { if(isLeapYear()) return 29; else return 28; } elseif((this.month == 1) || (this.month == 3) || (this.month == 5) || (this.month == 7) || (this.month == 8) || (this.month == 10) || (this.month == 12)) return 31; else return 30; } /** * Checks if this dat is same as other date * @param other * @return */ publicboolean isEqual(Date other) { if((this.day == other.day) && (this.month == other.month) && (this.year == other.year)) returntrue; else returnfalse; } /** * Moves this Date object forward in time by the given number of days . * @param days */ publicvoid addDays(int days) { while(days != 0){ int maxDays = maxMonthDays(); if((maxDays - this.day) >= days) { this.day += days;
  • 5. days = 0; } else{ days -= (maxDays - this.day); this.day = 0; if(month == 12) { this.month = 1; this.year += 1; } else this.month += 1; } } } /** * Moves this date object forward in time by the given amount of seven day weeks * @param weeks */ publicvoid addWeeks(int weeks) { addDays(weeks * DAYS_PER_WEEK); } /** * Returns the number of days that this Date must be adjusted to make it equal to the given other Date. * @param other * @return */ publicint daysTo(Date other) { Date temp = new Date(this.day, this.month, this.year); if(temp.isEqual(other)) return 0; else{ int noOfDays = 0; do { if((temp.year == other.year) && (temp.month == other.month)) { noOfDays += (other.day - temp.day); temp.day = other.day;
  • 6. } else{ int maxDays = temp.maxMonthDays(); noOfDays += (maxDays - temp.day); temp.day = 0; if(temp.month == 12) { temp.month = 1; temp.year += 1; } else temp.month += 1; } } while(!temp.isEqual(other)); return noOfDays; } } /** * Returns a String representation of this date in year/month/day order, such as "2006/07/22" */ @Override public String toString() { returnthis.day + DATE_SEPARATOR + this.month + DATE_SEPARATOR + this.year; } } publicclass Driver { publicstaticvoid main(String[] args) { Date d1 = new Date(29, 1, 2016); Date d2 = new Date(29, 12, 2015); //Add 5 days to d1 System.out.println(" Add 5 days to " + d1 + " : "); d1.addDays(5); System.out.println(d1); //Add 5 days to d2 System.out.println(" Add 5 days to " + d2 + " : "); d2.addDays(5); System.out.println(d2);
  • 7. Date d3 = new Date(28, 8, 2016); //Add 1 week to d3 System.out.println(" Add 1 week to " + d3 + " : "); d3.addWeeks(1); System.out.println(d3); Date d4 = new Date(31, 8, 2016); Date d5 = new Date(1, 10, 2016); System.out.println(" The number of days that " + d4 + " must be adjusted to make it equal to " + d5 + " : " + d4.daysTo(d5) + " days."); } } SAMPLE OUTPUT : Add 5 days to 29/1/2016 : 3/2/2016 Add 5 days to 29/12/2015 : 3/1/2016 Add 1 week to 28/8/2016 : 4/9/2016 The number of days that 31/8/2016 must be adjusted to make it equal to 1/10/2016 : 31 days. Solution publicclass Date { privatestatic String DATE_SEPARATOR = "/"; privatestaticintDAYS_PER_WEEK = 7; //Attributes privateint day; privateint month; privateint year; /** * Default Constructor * Instantiates an object of type Date to 1/1/2000 */ public Date() { this.day = 1; this.month = 1;
  • 8. this.year = 2000; } /** * Constructs a new date object to represent the given date. * @param day * @param month * @param year */ public Date(int day, int month, int year) { if(isValid(day, month, year)) { this.day = day; this.month = month; this.year = year; } else System.out.println("Invalid Date."); } /** * Returns the day value of this date for example, for the date 2006/07/22, returns 22. * @return */ publicint getDay() { return day; } /** * Returns the month value of this date ,for example, for the date 2006/07/22, returns 7. * @return */ publicint getMonth() { return month; } /** * Returns the year value of this date, for example , the date 2006/07/22, returns 2006. * @return */ publicint getYear() { return year;
  • 9. } /** * @param day the day to set */ publicvoid setDay(int day) { this.day = day; } /** * @param month the month to set */ publicvoid setMonth(int month) { this.month = month; } /** * @param year the year to set */ publicvoid setYear(int year) { this.year = year; } /** * Returns true if the year of this date is a leap year. * A leap year occurs every 4 years , except for multiples of 100 that are not multiples of 400. * For example, 1956,1844,1600,and 2000 are leap years, but 1983,2002,1700,and 1900 are not. * @return */ publicboolean isLeapYear(){ if(((this.year % 400) == 0) || (((this.year % 4) == 0) && ((this.year % 100) != 0))) returntrue; else returnfalse; } /** * Checks if the date is valid * @param day * @param month * @param year
  • 10. * @return */ publicboolean isValid(int day, int month, int year) { if((month < 1) || (12 < month)) returnfalse; else { if(((month == 1) || (month == 3) || (month == 5) || (month == 7) || (month == 8) || (month == 10) || (month == 12)) && ((day < 1) || (31 < day))) returnfalse; elseif(((month == 4) || (month == 6) || (month == 9) || (month == 11)) && ((day < 1) || (30 < day))) returnfalse; elseif(month == 2) { if(isLeapYear() && ((day < 1) || (29 < day))) returnfalse; elseif((day < 1) || (28 < day)) returnfalse; } } returntrue; } /** * Returns the maximum number of days in a month * @return */ publicint maxMonthDays() { if(this.month == 2) { if(isLeapYear()) return 29; else return 28; } elseif((this.month == 1) || (this.month == 3) || (this.month == 5) || (this.month == 7) || (this.month == 8) || (this.month == 10) || (this.month == 12)) return 31; else return 30;
  • 11. } /** * Checks if this dat is same as other date * @param other * @return */ publicboolean isEqual(Date other) { if((this.day == other.day) && (this.month == other.month) && (this.year == other.year)) returntrue; else returnfalse; } /** * Moves this Date object forward in time by the given number of days . * @param days */ publicvoid addDays(int days) { while(days != 0){ int maxDays = maxMonthDays(); if((maxDays - this.day) >= days) { this.day += days; days = 0; } else{ days -= (maxDays - this.day); this.day = 0; if(month == 12) { this.month = 1; this.year += 1; } else this.month += 1; } } } /** * Moves this date object forward in time by the given amount of seven day weeks
  • 12. * @param weeks */ publicvoid addWeeks(int weeks) { addDays(weeks * DAYS_PER_WEEK); } /** * Returns the number of days that this Date must be adjusted to make it equal to the given other Date. * @param other * @return */ publicint daysTo(Date other) { Date temp = new Date(this.day, this.month, this.year); if(temp.isEqual(other)) return 0; else{ int noOfDays = 0; do { if((temp.year == other.year) && (temp.month == other.month)) { noOfDays += (other.day - temp.day); temp.day = other.day; } else{ int maxDays = temp.maxMonthDays(); noOfDays += (maxDays - temp.day); temp.day = 0; if(temp.month == 12) { temp.month = 1; temp.year += 1; } else temp.month += 1; } } while(!temp.isEqual(other)); return noOfDays; }
  • 13. } /** * Returns a String representation of this date in year/month/day order, such as "2006/07/22" */ @Override public String toString() { returnthis.day + DATE_SEPARATOR + this.month + DATE_SEPARATOR + this.year; } } publicclass Driver { publicstaticvoid main(String[] args) { Date d1 = new Date(29, 1, 2016); Date d2 = new Date(29, 12, 2015); //Add 5 days to d1 System.out.println(" Add 5 days to " + d1 + " : "); d1.addDays(5); System.out.println(d1); //Add 5 days to d2 System.out.println(" Add 5 days to " + d2 + " : "); d2.addDays(5); System.out.println(d2); Date d3 = new Date(28, 8, 2016); //Add 1 week to d3 System.out.println(" Add 1 week to " + d3 + " : "); d3.addWeeks(1); System.out.println(d3); Date d4 = new Date(31, 8, 2016); Date d5 = new Date(1, 10, 2016); System.out.println(" The number of days that " + d4 + " must be adjusted to make it equal to " + d5 + " : " + d4.daysTo(d5) + " days."); } } SAMPLE OUTPUT : Add 5 days to 29/1/2016 : 3/2/2016 Add 5 days to 29/12/2015 :
  • 14. 3/1/2016 Add 1 week to 28/8/2016 : 4/9/2016 The number of days that 31/8/2016 must be adjusted to make it equal to 1/10/2016 : 31 days.