Hi everyone.
Welcome back to this tutorial.
In this tutorial, we will explore the local date class.
The first step is I'm going to create a class called.
Local date example.
And then I'm going to make this class executable by adding public static void main method.
Put this in presentation mode.
There we go.
The first step is we are going to create an instance of local data.
Local date.
Equal to new art, new local date dot now.
So this is what we did in the previous tutorial to.
When I printed.
Local date.
We know this is going to print the current machines local date.
There you go.
It printed the machine's current date.
What are the other options of creating this?
There are many more options.
Let's focus some of the options in this tutorial.
Local date Dot.
As soon as you click the dot.
The time zones are something which I'll be covering it in the future.
Tutorials for now I'm going to keep it on hold.
Let's explore the off method.
There you go.
If you have if you see the off method, it takes three arguments.
Right?
Let's given this, it takes three arguments.
What are the three arguments?
The three arguments are year, month and day of month.
So the first one is year.
And then the month I'm going to give the month as zero seven and then the day I'm going to give it as
17th.
The current machines time date is 16th and I gave the date as 17 here.
So as soon as you make this call, what is this method going to return?
This is going to return an instance of local date.
So I'm going to give local date.
I'm going to give it a name.
It's going to be local date one.
And let's print this.
Printed going to print the current the date of this local date.
One instance is going to be 17 because that's what we are passing here.
The day of the month is 17 and it printed the value as 17.
Let's explore the another of method version of creating the local data of.
There are two different versions of it.
One is the year day and another one is the Epoch Day.
Epoch Day is something which we will cover in the future tutorials.
For now, we will cover the year Day takes in two parameters.
One is the year I'm going to give the value as 2018 and the next parameter is the day of the year.
Let's see, I'm going to pass the value as 365 and then see what is the value that it is going to print.
Local date, local date to equal to This is good.
I'm going to print and check what is the result.
The result that it is going to print is going to be.
31, 12, 2018, which is the last day of the year.
So in this version, if you pass the value as zero two and then check, the result is going to give
you Jan second 2018 as a result.
There you go.
So this takes in the day of the year and then gives you the appropriate date as a response.
Now we know how to create the date instance.
Let's say you want to read the values from these date.
Let's say you want to read just the month or just the day of the year or day of the week.
How do we do it?
So.
Let's talk about how to get.
Values from local data.
Okay.
The first one is I want to get the month.
How can I do that?
The way to do it is by.
Following the get month method.
If you take a look at it as soon as I typed in git, there are a lot of options here.
Get year, get day of year, get day of week, month value month, chronology, day of month, get era
long.
For now I'm going to focus just a few methods.
I would highly recommend you to explore all the methods and then find out what you can read from this
date instance.
I'm going to do get month.
Get month.
Let's print and check.
What is that?
It is going to return.
On this.
The value it printed is July because that is the current month of this.
Local date.
Let's say you want to get the month value, so not the month name.
You want to know the month value.
In that case, you can call this get month value method that is going to give you the month value as
a response.
The month value is seven.
Let's say you want to read the day of the week.
What?
Can we do it?
Copy this here.
Paul get day of the week.
Let's see, what is the response that it is going to return as part of it?
So it returned the day of the week as Monday.
Let's say you want to check what is a day of the year like how we calculated it here.
Right.
We want to calculate that get day of year.
This year.
And this.
It gave you the value as 197 197 is a current day of the year and you can play around with all the other
methods and then please shoot me a question or post any questions in the Q&A if you have any doubts
on this.
And then let's take a look at the next method.
What are the other different ways of getting the value?
Here?
We use the methods that this local date instance supports, right?
Let's say we want to just call the get method.
So there is a get method which takes in an input call temporal field here.
Right, let's go and check.
So this one is accepting a field called temporal field.
So what is a temporal field?
There is something called Chrono Field.
If you go to this class, this class implements the temporal field, let's say, what are the values
that this temporal field has?
Sorry.
It's not a class.
It's a enum.
It has a lot of different values, like nanosecond and nanotech.
So what we want in this one, let's say you want to just get the day of the month.
Right.
We just passed that and is going to give you.
Day of month.
Using git.
Right.
And then if you run this program, it is going to give you the day of the month of this particular.
Date instance.
Let's explore some of the other properties, like modifying the date and what are the different scenarios
it supports in the future tutorials.
But this we came to the end of this tutorial.
Thank you for watching.