Wxyz
Wxyz
1. Write a program to display the current date and add 1 week, 1 month,1
year and 10 years to the current date and print.
Program:
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
/*
* Current date: 2024-03-29
*/
import java.util.Date;
String dateToStr =
DateFormat.getInstance().format(currentDate);
dateToStr =
DateFormat.getDateInstance().format(currentDate);
dateToStr =
DateFormat.getDateTimeInstance().format(currentDate);
dateToStr =
DateFormat.getTimeInstance(DateFormat.SHORT).format(currentDate);
dateToStr =
DateFormat.getTimeInstance(DateFormat.MEDIUM).format(currentDate);
dateToStr =
DateFormat.getTimeInstance(DateFormat.LONG).format(currentDate);
dateToStr = DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.SHORT).format(currentDate);
/*
*/
3. Write a program to print local date and check whether the year is leap year
or not.
import java.time.LocalDate;
/*
*/
4. Write a program to get the period between two dates and duration
between two times.
import java.time.temporal.ChronoUnit;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Duration;
import java.time.Period;
/*
* Time2: 21:19:34.266723900
*/
5. Write a program to print a zone with date ,zone id and current zone.
import java.time.ZonedDateTime;
import java.time.ZoneId;
ZoneId id = ZoneId.of("Europe/Paris");
/*
* date1: 2007-12-03T09:45:30+05:00[Asia/Karachi]
* ZoneId: Europe/Paris
* CurrentZone: Asia/Calcutta
* PS C:\Users\nikit>
*/
import java.util.Date;
/*
*/
int decimal = 0;
int n = 0;
while (true) {
if (binary == 0) {
break;
} else {
n++;
return decimal;
/*
*/
String st = "18";
System.out.println(bn);
System.out.println(Integer.parseInt("f", 16));
System.out.println(Integer.parseInt("125", 16));
}
9. Write a program to encode and decode JSON object in PHP.
Encode:
if(window.XMLHttpRequest){
request=new XMLHttpRequest();//for Chrome, mozilla etc
}
else if(window.ActiveXObject){
request=new ActiveXObject("Microsoft.XMLHTTP");//for IE only
}
request.onreadystatechange = function(){
if (request.readyState == 4 )
{
var jsonObj = JSON.parse(request.responseText);//JSON.parse() returns
JSON object
document.getElementById("date").innerHTML = jsonObj.date;
document.getElementById("time").innerHTML = jsonObj.time;
}
}
request.open("GET", url, true);
request.send();
}
</script>
</head>
<body>
Date: <span id="date"></span><br/>
Time: <span id="time"></span><br/>