0% found this document useful (0 votes)
14 views

all program

Uploaded by

chetan chaudhari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

all program

Uploaded by

chetan chaudhari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

import java.util.

Scanner;
public class sara
{
public static void main(String[] args)
{
int ch,x;
Scanner sc = new Scanner(System.in);
System.out.println("1. Positive or Negative");
System.out.println("2. Even or Odd");
System.out.println("3. Exit");

System.out.println("enter your choice");


ch=sc.nextInt();

System.out.println("enter any one number");


x=sc.nextInt();
switch(ch)
{

case 1:
if(x>=0)
System.out.println("number is positive");
else
System.out.println("number is negative");
break;

case 2:
if(x%2==0)
System.out.println("number is Even");
else
System.out.println("number is odd");
break;
default: System.out.println("wrong choice");

}
}
}

import java.time.LocalDate; // import the LocalDate class

public class date1


{
public static void main(String[] args)
{
LocalDate myObj = LocalDate.now(); // Create a date object
System.out.println(myObj); // Display the current date
}
}
import java.time.LocalTime; // import the LocalTime class

public class date2


{
public static void main(String[] args)
{
LocalTime myObj = LocalTime.now();
System.out.println(myObj);
}
}

import java.time.LocalDateTime; // import the LocalDateTime class

public class date3


{
public static void main(String[] args)
{
LocalDateTime myObj = LocalDateTime.now();
System.out.println(myObj);
}
}
import java.time.LocalDateTime; // Import the LocalDateTime class
import java.time.format.DateTimeFormatter; // Import the DateTimeFormatter class

public class date4


{
public static void main(String[] args)
{
LocalDateTime myDateObj = LocalDateTime.now();
System.out.println("Before formatting: " + myDateObj);
DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("dd-MM-
yyyy HH:mm:ss");

String formattedDate = myDateObj.format(myFormatObj);


System.out.println("After formatting: " + formattedDate);
}
}

import java.time.LocalDateTime; // Import the LocalDateTime class


import java.time.format.DateTimeFormatter; // Import the DateTimeFormatter
class

public class date5


{
public static void main(String[] args)
{
LocalDateTime myDateObj = LocalDateTime.now();
System.out.println("Before Formatting: " + myDateObj);
DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("E, MMM
dd yyyy HH:mm:ss");

String formattedDate = myDateObj.format(myFormatObj);


System.out.println("After Formatting: " + formattedDate);
}
}

// Note: This example displays the server's local time, which may differ from your
local time.

You might also like