标签:
/** * * @param string 时间 * @param height控件的高度 * @return */ //"9:00-20:45" private int[] prosessTime1(String string,int height) { string=string.trim().toString(); String[] split = string.split("-"); // System.out.println("split[0]:"+split[0]+"------------split[1]:"+split[1]); int[] prosessTime2 = prosessTime2(split[0],split[1],height); return prosessTime2; } /** * 把"9:00-20:45"格式的数转化为控件尺寸位置所需的数据 * @param string */ private int[] prosessTime2(String str0,String str1,int height) { int[] data=new int[2]; for (int i = 0; i < 2; i++) { if(i==1){ str0=str1; } //获取第1位字符 String substring0 = str0.substring(0, 1); String substring1 = str0.substring(2, 3); //09:00-12:00 if(substring0.equals("0")&&substring1.equals(":")){ str0 = str0.substring(1,2)+str0.substring(3, 5); //12:00 }else if(substring1.equals(":")){ str0 = str0.substring(0,2)+str0.substring(3, 5); //9:00 }else{ str0 = str0.substring(0,1)+str0.substring(2, 4); } float fl_1 = Float.parseFloat(str0); float fl_2=fl_1/900; int int_3=(int) (fl_2*height/(9/24)); data[i]=int_3; System.out.println("<--------fl_1-------->"+fl_1); System.out.println("<---------fl_2------->"+fl_2); System.out.println("<----------int_3------>"+int_3); } System.out.println(+data[0]+"<-------------->"+data[1]); return data; }
标签:
原文地址:http://www.cnblogs.com/a454892215/p/4401055.html