1 PackageHomework7;2 3 ImportJava.util.Scanner;4 5 Public classTime {6 Static intYear ;7 Static intmonth;8 Static intDay ;9 Static inthour;Ten Static intMintue; One Static intsecond; A PublicTime (intYearintMonthintDayintHourintMintue,intsecond) { - This. year=Year ; - This. month=month; the This. day=Day ; - This. hour=hour; - This. mintue=Mintue; - This. second=second; + } - /** + * A simple way to convert time A * at */ - Public voidShowTime () { - - System.out.println - //("Set Time:" +getyear () + "Year" +getmonth () + "month" +getday () + "Day" +gethour () + "Hour" +getmintue () + "Min" +getsecond () + "seconds"); -("Set Time:" +year+ "year" +month+ "month" +day+ "Day" +hour+ "when" +mintue+ "minute" +second+ "seconds"); in } - to PublicTime () { + - } the * Public Static voidMain (string[] args) { $ //Enter a time valuePanax Notoginseng /*Scanner sc = new Scanner (system.in); - System.out.println ("Please Enter seconds:"); the int second = Sc.nextint (); + System.out.println ("Please enter points:"); A int mintue = Sc.nextint (); the System.out.println ("Please enter:"); + int hour = Sc.nextint (); - System.out.println ("Please enter the day:"); $ int day = Sc.nextint (); $ System.out.println ("Please enter the month:"); - int month = Sc.nextint (); - System.out.println ("Please enter the Year:"); the int year = Sc.nextint (); - Wuyi Time ti = new Time (year,month,day,hour,mintue,second);*/ theTime Ti =NewTime (2016,11,29,24,59,60); - /*Ti.sethour (+); Wu ti.setmintue (); - Ti.setsecond ();*/ About $ //the conversion of time to judge - //seconds to turn the score - if(second<60){ -Second=second; AMintue=Mintue; + } the if(second>=60){ - if(second%60==0){ $Mintue=mintue+second/60; theSecond=0; the } the if(second%60!=0){ theMintue=mintue+second/60; -Second=second%60; in }} the //at the time of transfer the if(mintue<60){ AboutMintue=Mintue; theHour=hour; the } the if(mintue>=60){ + if(mintue%60==0){ -Hour=hour+mintue/60; theMintue=0;Bayi } the if(mintue%60!=0){ theHour=hour+mintue/60; -Mintue=mintue%60; - }} the //time to turn day the if(hour<24){ theHour=hour; theday=Day ; - } the if(hour>=24){ the if(hour%24==0){ theDay=day+hour/24;94Hour=0; the } the if(hour%24!=0){ theDay=day+hour/24;98Hour=hour%24; About }} - //Day Turn Month101 if(day<30){102day=Day ;103Month=month;104 } the if(day>=30){106 if(day%30==0){107Month=month+day/30;108Day=1;109 } the if(day%30!=0){111Month=month+day/30; theDay=day%30;113 }} the //month following year the if(month<12){ theMonth=month;117Year=Year ;118 }119 if(year>=12){ - if(month%12==0){121Year=year+month/12;122Month=1;123 }124 if(month%12!=0){ theYear=year+month/12;126Month=month%12;127 }} - //call Showtime129 ti.showtime (); the }131 the 133}
Java Beginner with wind notes-simple time conversion