1 /**2 * @paramdata yyyy-mm-dd HH:mm:ss time3 * @returnclosed in open trades4 */5 Public Staticstring Getsotckstatus (String data) {6String s = "";7 Try {8SimpleDateFormat SDF =NewSimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");9Date date1 =sdf.parse (data);TenCalendar cal =calendar.getinstance (); One Cal.settime (date1); A //Calendar cal = Calendar.getinstance (); - inthour =Cal.get (calendar.hour_of_day); - intminutes =Cal.get (calendar.minute); the if(Hour >= 0 && Hour < 10) { - if(Hour >= 9) { - if(Minutes >= 30)//9:30-10:00 -s = "in Trading"; + Else - //9:00-9:30 +s = "Not open"; A}Else{//0:00-9:00 ats = "Not open"; - } -}Else if(Hour > 9 && Hour < 12) { - if(Hour > 10) { - if(Hour >= 11) { - if(Minutes >= 30)//11:30-12:00 ins = "in Rest"; - Else to //11:00-11:30 +s = "in Trading"; -}Else{//10:00-11:00 thes = "in Trading"; * } $}Else {Panax Notoginseng if(Minutes >= 30)//9:30-10:00 -s = "in Trading"; the Else + //9:00-9:30 As = "Not open"; the } +}Else if(Hour >= && Hour < 13) { - if(Hour < 12) { $ if(Minutes >= 30)//11:30-12:00 $s = "in Rest"; - Else - //11:00-11:30 thes = "in Trading"; -}Else {Wuyis = "in Rest"; the } -}Else if(Hour > && Hour < 15) { Wu if(Hour >= 13) {//13:00-15:00 -s = "in Trading"; About}Else{//12:00-13:00 $s = "in Rest"; - } -}Else if(Hour >= && hour <= 24) {//15:00-24:00 -s = "Closed"; A } +}Catch(Exception e) { the e.printstacktrace (); - returns; $ } the returns; the}
Android/java stock trading status based on current time (closed in open trades)