WEBVTT

00:00.080 --> 00:00.560
Hi everyone.

00:00.560 --> 00:01.850
Welcome back to this tutorial.

00:01.850 --> 00:08.330
In this tutorial, we will explore the options of modifying the local date that we created and explore

00:08.330 --> 00:11.570
some of the additional methods that local date supports.

00:11.570 --> 00:14.690
Let's start with modifying the local date instance.

00:15.320 --> 00:17.150
I'll give a quick comment here.

00:17.450 --> 00:20.810
Modifying local date.

00:22.840 --> 00:23.590
No.

00:24.510 --> 00:29.550
We have the current date as let's run this example and check what is the current date.

00:29.670 --> 00:31.730
The current date is 16.

00:31.740 --> 00:34.800
I want to increment the date by two days.

00:34.800 --> 00:35.790
How do I do it?

00:36.710 --> 00:43.070
The local date instance supports a lot of handy methods that can that we can use in order to achieve

00:43.070 --> 00:43.910
our goal.

00:44.060 --> 00:51.350
So as soon as I type in plus it gives me all these options you can do plus days, plus years plus weeks

00:51.350 --> 00:52.310
plus months.

00:52.790 --> 00:54.830
I'm going to explore a couple of options here.

00:54.830 --> 00:57.590
I would highly recommend you guys to explore all the options.

00:57.620 --> 01:00.830
Our use cases, we want to increment the days by two, right?

01:00.830 --> 01:07.910
So in that case we can do plus days and then you have to pass the integer.

01:07.910 --> 01:14.330
So if you take a look at the input to this method, it is just the long it was not integer, it is long.

01:14.330 --> 01:17.120
You just have to give how many days you want to increment.

01:17.150 --> 01:19.880
So here I want to increment the days by two.

01:19.910 --> 01:22.190
So that's the reason why I'm passing the days as two.

01:22.580 --> 01:24.350
Let's check this result.

01:27.690 --> 01:32.370
So the current date is 16 after we run this example.

01:33.710 --> 01:35.300
Let's take a look at the current date.

01:36.830 --> 01:41.690
Though the current date is going to be the local date instance date is going to be 18.

01:41.690 --> 01:47.360
And one more thing, if you notice, it doesn't change the actual instance that got created initially

01:47.360 --> 01:54.620
because as I mentioned in the presentation, all the local date instances that we create are immutable.

01:54.620 --> 02:00.110
So if we go and take a look at the prejudice method, basically this is going to return a new local

02:00.110 --> 02:04.100
date instance using the local date dot off of Epoch Day.

02:04.160 --> 02:09.340
Basically this doesn't disturb the local date instance that we created at all.

02:09.350 --> 02:13.220
So this is one of the important thing to keep in your mind.

02:13.250 --> 02:18.800
This helps us build the programs in functional approach and want to increase the month.

02:18.800 --> 02:19.820
How can we do it?

02:20.120 --> 02:22.220
There is a handy method called.

02:23.640 --> 02:28.140
Last months and I'm going to increase the month by two months.

02:28.140 --> 02:30.540
That's the reason why I'm passing the value as two.

02:30.870 --> 02:36.270
And if I run it, you'll be able to see the value as nine here in the place of seven.

02:36.300 --> 02:36.780
There you go.

02:36.780 --> 02:39.000
It printed the value as nine.

02:39.000 --> 02:44.940
And if you take a look at the date, date is again 16 because as I mentioned, every time it is going

02:44.940 --> 02:51.600
to create a new date instance, that's the reason why this local date is still pointing to the 16th,

02:51.600 --> 02:53.220
which is a current date.

02:53.520 --> 02:55.740
I want to decrease the date by two days.

02:55.740 --> 02:56.700
How do I do it?

02:57.000 --> 02:59.220
So there is a handy method called.

03:00.060 --> 03:01.170
Minus.

03:02.580 --> 03:03.360
In minors.

03:03.360 --> 03:06.880
If you want to decrease the dates by two, I'll pass two.

03:06.900 --> 03:12.180
And this is going to decrease the date and it is going to print the date as 14.

03:15.360 --> 03:15.780
There you go.

03:15.780 --> 03:19.710
It printed the date is 14 and the current date is 16.

03:20.370 --> 03:22.770
Now, these are the handy methods.

03:22.770 --> 03:25.410
You can modify the date, right?

03:25.410 --> 03:27.870
There are some more options, like with.

03:28.320 --> 03:29.610
Let's explore that as part of this.

03:29.610 --> 03:32.040
Now the local date.

03:34.150 --> 03:36.150
That we type in width.

03:36.180 --> 03:37.770
Width has two different.

03:37.800 --> 03:38.300
Not two.

03:38.340 --> 03:40.380
Three different variations.

03:40.410 --> 03:42.060
Let's say you want to change a year.

03:42.390 --> 03:44.940
You can change it by passing the width year.

03:44.940 --> 03:47.400
I'm going to change the year as 2019.

03:47.430 --> 03:49.170
Let's go ahead and check the result.

03:49.200 --> 03:51.240
Again, this is going to be immutable.

03:51.240 --> 03:54.120
It does not going to change the current state of local date.

03:54.180 --> 04:00.000
It is going to give you a new date and it doesn't disturb the current local date instance.

04:00.000 --> 04:05.250
If you take a look at it, the year got changed to 2019 from 2018.

04:05.280 --> 04:08.760
Now let's take a look at some more options with.

04:10.350 --> 04:13.170
The word has many different versions now.

04:13.200 --> 04:17.400
We are going to explore the one with the temporal field.

04:18.450 --> 04:20.550
The temporal field is something.

04:21.940 --> 04:24.880
Similar to the Chrono Field we are going to pass.

04:25.330 --> 04:27.820
Let's say you want to change the year.

04:28.090 --> 04:29.320
There are a lot of different options.

04:29.350 --> 04:32.530
If you take a look at it, it supports a lot of different options.

04:32.530 --> 04:38.200
But here, in order to keep the example simple, what I'm going to do, I'm going to do the year.

04:38.440 --> 04:40.420
You want to change the hour of the day?

04:40.420 --> 04:42.130
You can pass the hour of the day.

04:42.160 --> 04:44.230
You want to change the month of the year.

04:44.230 --> 04:47.890
You can pass by calling this enum constant.

04:47.890 --> 04:50.230
So here I'm going to change the year, right?

04:50.590 --> 04:53.080
I want to change the year to 2020.

04:54.250 --> 04:57.790
Soviet Chrono Field.

05:00.930 --> 05:05.010
Donna Field I'm going to put it down so that it will be visible throughout the presentation.

05:05.040 --> 05:09.930
Now, if I run this example, the date is going to be 2020.

05:09.960 --> 05:12.900
As you see here, the date got changed to 2020.

05:12.990 --> 05:17.070
And let's explore the other option, which is the temporal adjusters.

05:18.070 --> 05:18.970
Don't check that.

05:20.980 --> 05:22.330
I'll copy the same thing.

05:22.570 --> 05:24.820
So we are going to explore the width method only.

05:25.150 --> 05:27.280
The width method has.

05:31.640 --> 05:34.610
Some reason it is acting weird.

05:34.790 --> 05:38.690
Okay, now we are going to use the temporal adjusters.

05:38.720 --> 05:45.470
Temporal adjusters are something which is part of the Java runtime package, and it supports a lot of

05:45.470 --> 05:46.850
handy functionalities for you.

05:46.850 --> 05:49.820
Let's say you want to get the first day of the next month.

05:49.820 --> 05:52.400
You want to set that date to be the first day of next month.

05:52.430 --> 05:55.250
You can call that one and it has a lot of additional methods.

05:55.250 --> 05:59.750
I would highly recommend you guys to go through it and post any kind of questions in the Q&amp;A.

05:59.750 --> 06:02.930
I'll be able to respond to you as fast as I can.

06:03.140 --> 06:10.040
So I want the first day of next month to be set against this local date instance in that case.

06:11.840 --> 06:12.590
What to name this one.

06:12.590 --> 06:15.800
As with temporal adjusters, we run this example.

06:15.800 --> 06:21.200
It is going to give me the date as the first month, meaning first day of the next month.

06:21.200 --> 06:24.620
The next month is zero eight and the first day is zero one.

06:24.770 --> 06:30.830
If you compare this with the earlier versions of date and Time libraries that are part of Java, the

06:30.830 --> 06:33.920
new additions are really handy and intuitive.

06:33.950 --> 06:39.680
This means the local date to be the first choice to use when you are building some functionalities that

06:39.680 --> 06:41.300
are related to date.

06:41.330 --> 06:45.950
Let's go ahead and explore some more additional features that are part of the local date in the upcoming

06:45.980 --> 06:46.880
tutorials.

06:46.930 --> 06:49.020
With this, we came to the end of this tutorial.

06:49.040 --> 06:50.180
Thank you for watching.
