// 01. java. util. date --> JAVA. Time. localdatetime
Public void udatetolocaldatetime (){
Java. util. Date = new java. util. Date ();
Instant instant = date. toinstant ();
Zoneid zone = zoneid. systemdefault ();
Localdatetime = localdatetime. ofinstant (instant, zone );
}
// 02. java. util. date --> JAVA. Time. localdate
Public void udatetolocaldate (){
Java. util. Date = new java. util. Date ();
Instant instant = date. toinstant ();
Zoneid zone = zoneid. systemdefault ();
Localdatetime = localdatetime. ofinstant (instant, zone );
Localdate = localdatetime. tolocaldate ();
}
// 03. java. util. date --> JAVA. Time. localtime
Public void udatetolocaltime (){
Java. util. Date = new java. util. Date ();
Instant instant = date. toinstant ();
Zoneid zone = zoneid. systemdefault ();
Localdatetime = localdatetime. ofinstant (instant, zone );
Localtime = localdatetime. tolocaltime ();
}
// 04. java. Time. localdatetime --> JAVA. util. Date
Public void localdatetimetoudate (){
Localdatetime = localdatetime. Now ();
Zoneid zone = zoneid. systemdefault ();
Instant instant = localdatetime. atzone (Zone). toinstant ();
Java. util. Date = date. From (instant );
}
// 05. java. Time. localdate --> JAVA. util. Date
Public void localdatetoudate (){
Localdate = localdate. Now ();
Zoneid zone = zoneid. systemdefault ();
Instant instant = localdate. atstartofday (). atzone (Zone). toinstant ();
Java. util. Date = date. From (instant );
}
// 06. java. Time. localtime --> JAVA. util. Date
Public void localtimetoudate (){
Localtime = localtime. Now ();
Localdate = localdate. Now ();
Localdatetime = localdatetime. Of (localdate, localtime );
Zoneid zone = zoneid. systemdefault ();
Instant instant = localdatetime. atzone (Zone). toinstant ();
Java. util. Date = date. From (instant );
}
Localdate and date conversion