Question
I need UML Diagrams for this code package chegg_programs; import java.util.*; import java.time.*; import java.lang.Math; import java.text.*; public class DateAndTime { public static void main(String[]
I need UML Diagrams for this code
package chegg_programs;
import java.util.*; import java.time.*; import java.lang.Math; import java.text.*;
public class DateAndTime { public static void main(String[] args) { //Creating instance for date class Date date = new Date(); //Creating instance for calendar class Calendar c = Calendar.getInstance(); GregorianCalendar geocal = new GregorianCalendar(); //It will pass date object to setTime method and creates date string c.setTime(date); long time = date.getTime(); SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd"); //Displaying Year , month and day of current date System.out.println("Current Year, Month and Day : " + simpleDate.format(date)); //Displaying date using tostring System.out.println("Current Date : " + date.toString()); //Displaying time in milliseconds System.out.println("Current time (the number of milliseconds) : " + time); //Displaying using Gregorian Calendar Methods as given. System.out.println("Current Year : " + geocal.get(GregorianCalendar.YEAR)); System.out.println("Current Month : " + (geocal.get(GregorianCalendar.MONTH)+1)); System.out.println("Current Day : " + geocal.get(GregorianCalendar.DAY_OF_MONTH)); System.out.println("Current Week : " + geocal.get(GregorianCalendar.DAY_OF_WEEK)); System.out.println("Current DAY OF WEEK IN MONTH : " + geocal.get(GregorianCalendar.DAY_OF_WEEK_IN_MONTH)); System.out.println("Current Day of Year : " + geocal.get(GregorianCalendar.DAY_OF_YEAR)); System.out.println("Current Hour : " + geocal.get(GregorianCalendar.HOUR)); System.out.println("Current Hour of day: " + geocal.get(GregorianCalendar.HOUR_OF_DAY)); System.out.println("Current MINUTE : " + geocal.get(GregorianCalendar.MINUTE)); System.out.println("Current Second : " + geocal.get(GregorianCalendar.SECOND)); System.out.println("Current Millisecond : " + geocal.get(GregorianCalendar.MILLISECOND)); System.out.println("Current Week of month : " + geocal.get(GregorianCalendar.WEEK_OF_MONTH)); System.out.println("Current Week of year : " + geocal.get(GregorianCalendar.WEEK_OF_YEAR)); geocal.setTime(date); //For loop to add milliseconds to current time for(int i=0;i<12;i++) { geocal.add(GregorianCalendar.MILLISECOND, (int)Math.pow(10, i)); date = geocal.getTime(); System.out.println("The time after adding "+ (long)Math.pow(10, i) + " milliseconds : " + date); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started