package com.xyd.common.utils;
import org.apache.commons.lang.ArrayUtils;
import java.io.Serializable;
public class WeekUtils implements Serializable {
private static String weeklist="";
private static String weeklist2="";
public static String getweek(String week){
// System.out.println("运行一次");
weeklist2="";
weeklist="";
char[] charArray = week.toCharArray();
int arr[]= new int[charArray.length];
if(charArray.length>0) {
for (int i = 0; i < charArray.length; i++) {
if(ArrayUtils.isNotEmpty(charArray)){
int num=0;
try {
num = Integer.parseInt(String.valueOf(charArray[i]));
System.out.println(num+"num:");
}catch (Exception e){
e.printStackTrace();
}
arr[i] = num;}
}
for (int i = 0; i < arr.length; i++) {
// System.out.print(arr[i]);
weeklist2 = getWeekFormat(arr[i]);
}
}
return weeklist2;
}
public static String getWeekFormat(int weeks2){
// Integer weeks2 = Integer.valueOf(weeks);
if(weeks2==1){
weeklist+="星期一"+";"+"\n";
} else if(weeks2==2){
weeklist+="星期二"+";"+"\n";
}
else if(weeks2==3){
weeklist+="星期三"+";"+"\n";
} else if(weeks2==4){
weeklist+="星期四"+";"+"\n";
} else if(weeks2==5){
weeklist+="星期五"+";"+"\n";
} else if(weeks2==6){
weeklist+="星期六"+";"+"\n";
} else if(weeks2==7){
weeklist+="星期日"+";"+"\n";
}
return weeklist;
}
/*public static void main(String[] args) {
String getweek = getweek("123");
System.out.println(getweek);
}*/
}
工具类将(1,3,5)转换为星期一;星期三;星期五
最新推荐文章于 2022-10-12 19:49:25 发布