WEBVTT

00:00.980 --> 00:01.550
Hi everyone.

00:01.550 --> 00:02.720
Welcome back to this tutorial.

00:02.720 --> 00:09.860
In this tutorial we will code and explore how to convert a local date and local time to a local date

00:09.860 --> 00:17.090
and time, and how to get a local date and local time from a local date time instance.

00:17.510 --> 00:18.980
Let's go ahead and code this one.

00:22.880 --> 00:24.230
Though the use cases.

00:26.340 --> 00:27.360
Converting.

00:28.390 --> 00:29.620
Local date.

00:30.610 --> 00:34.120
And local time to local date time.

00:35.310 --> 00:36.480
And vice versa.

00:39.290 --> 00:42.170
The first thing is let's create an instance of local date.

00:44.660 --> 00:48.470
Let's give it a name and it's going to be local date.

00:52.260 --> 00:52.740
Off.

00:53.280 --> 00:58.710
I'm going to give the year 2019 zero one and zero one.

00:59.340 --> 01:01.670
So we have the local date instance already.

01:01.680 --> 01:05.310
How can we get a local date time from this?

01:05.760 --> 01:08.430
So we take a look at the local date.

01:08.460 --> 01:10.800
There is a handy method called add time.

01:10.980 --> 01:17.580
If you pass the hour and minute here, I'm going to pass the minute as 23, comma 33.

01:18.710 --> 01:26.960
So what this is going to do, this is going to add these times to the date and then return the local

01:26.960 --> 01:28.910
date and time as a response.

01:29.920 --> 01:30.390
Let's go.

01:30.490 --> 01:35.100
Go ahead and check what is what is this method does actually, we take a look at it.

01:35.110 --> 01:38.800
It returns the local date time as a output.

01:38.800 --> 01:41.740
But if you take a look at it, it converts.

01:43.150 --> 01:50.140
The date that we are passing and then adding the time to it so that it can be able to return a local

01:50.140 --> 01:50.920
date time.

01:50.920 --> 01:58.450
So we if you remember, we have explored a method called local date dot off, which takes a local date

01:58.450 --> 02:02.050
and local time and returns the local date time as a output.

02:02.080 --> 02:03.970
That's what it does behind the scenes.

02:04.540 --> 02:05.980
Let's run this example.

02:06.610 --> 02:08.290
I'm going to remove the semicolon here.

02:09.320 --> 02:11.480
Let's run this example and check the result.

02:12.410 --> 02:17.660
So if you take a look at that time, it has both the date and time as a output.

02:17.690 --> 02:24.140
Now let's explore how to get a local date time from a local time instance.

02:25.710 --> 02:26.550
Local time.

02:27.270 --> 02:28.260
Local time.

02:28.260 --> 02:30.210
Equal to local time.

02:30.220 --> 02:32.370
Dot of.

02:33.800 --> 02:36.550
I'm going to give the value as 2359.

02:37.970 --> 02:47.040
Okay in here, we are going to add date to it and then get the local date time as a output.

02:47.060 --> 02:49.100
So local time.

02:50.510 --> 02:57.510
But there is a handy method called at date to which we have to pass the date.

02:57.530 --> 03:01.850
What I'm going to do, I'm going to pass the date instance that we created here.

03:03.570 --> 03:06.270
Let's run this and check the result.

03:09.290 --> 03:10.430
It's going to be.

03:12.290 --> 03:13.430
At date.

03:16.180 --> 03:18.310
Okay, let's run this and check the example.

03:19.170 --> 03:21.130
I'll remove this extra semicolon here.

03:24.620 --> 03:30.280
If you take a look at the update, the output is the combination of date and time.

03:30.280 --> 03:37.570
This is these are the different approaches of converting a date to a local date and time, yet time

03:37.570 --> 03:39.900
to a local date and time.

03:39.910 --> 03:46.150
How can we get a local date and local time from the local date and time instance?

03:46.180 --> 03:47.710
So what I'm going to do.

03:48.750 --> 03:50.190
I'm going to copy this code.

03:51.430 --> 03:56.560
So we all know this is going to give us the local date and time as an output.

03:57.040 --> 03:59.830
So I'm going to give it a name from this instance.

03:59.830 --> 04:03.940
I'm going to get the local date and local time as an output.

04:04.330 --> 04:05.380
How do I do it?

04:06.220 --> 04:10.630
So we use this date time three instance.

04:10.900 --> 04:11.680
We take a look at it.

04:11.680 --> 04:13.840
There is a method called to local data.

04:14.170 --> 04:20.800
So this to local date will just give you the date out of the local date and time instance.

04:21.160 --> 04:22.600
I'm going to print it here.

04:25.920 --> 04:30.030
And then I'm going to do the similar thing for the time.

04:30.600 --> 04:32.100
Go ahead and check what is the method it has.

04:32.100 --> 04:38.580
It has a two local time method which will just give you the time out of the local date and time instance.

04:39.700 --> 04:41.890
Okay, let's run this and check the result.

04:44.750 --> 04:45.230
There you go.

04:45.230 --> 04:47.660
It printed the result for the two local date.

04:47.660 --> 04:50.300
It printed the date and two local time.

04:50.300 --> 04:52.040
Just printed the time.

04:52.610 --> 04:59.750
So these are the different approaches of getting the local date and time from a local date time instance

04:59.750 --> 05:06.950
and converting a local date and local time to a local date time instance.

05:06.950 --> 05:09.110
With this, we came to the end of this tutorial.

05:09.140 --> 05:10.280
Thank you for watching.
