工具类将(1,3,5)转换为星期一;星期三;星期五

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);
    }*/
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值