如何在java中打印Hijrah月?

时间:2017-02-19 08:33:03

标签: java monthcalendar hijri

任何下面几个月都要关联的词汇?

1 Muharram
2 Safar
3 Rabi\u02bb I
  Rabi\u02bb II
  Jumada I
  Jumada II
  Rajab
  Sha\u02bbban
  Ramadan
  Shawwal
  Dhu\u02bbl-Qi\u02bbdah
  Dhu\u02bbl-Hijjah

1 个答案:

答案 0 :(得分:2)

查看Time4j图书馆,日历项目。

Maven依赖:

Stream.of(HijriMonth.values()).forEach(v->
            System.out.println("Display name: " + v.getDisplayName(Locale.US) + " month index: " + v.getValue()));

示例:

Display name: Muharram month index: 1
Display name: Safar month index: 2
Display name: Rabiʻ I month index: 3
Display name: Rabiʻ II month index: 4
Display name: Jumada I month index: 5
Display name: Jumada II month index: 6
Display name: Rajab month index: 7
Display name: Shaʻban month index: 8
Display name: Ramadan month index: 9
Display name: Shawwal month index: 10
Display name: Dhuʻl-Qiʻdah month index: 11
Display name: Dhuʻl-Hijjah month index: 12

输出:

   private View.OnClickListener buttonClickListerner = new
   View.OnClickListener() {
    float r;
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.clear:
                screen.setText("");
                operator.setText("");
                FirstNum= 0;
                showtext.setText("");
                break;
            case R.id.buttonAdd:
                mMath("+");
                operator.setText("+");
                showtext.setText(String.valueOf(FirstNum));
                break;
            case R.id.buttonMinus:
                mMath("-");
                operator.setText("-");
                break;
            case R.id.buttonMul:
                mMath("*");
                operator.setText("*");
                break;
            case R.id.buttonequal:
                mResult();
                break;
            case R.id.buttonDiv:
                mMath("/");
                operator.setText("/");
                break;
            case R.id.buttonPercent:
                mMath("%");
                r =  FirstNum / 100;
                showtext.setText("[" + String.valueOf(FirstNum) + "%" + "]");    
                screen.setText(String.valueOf(r));
                break;
            default:
                String num = ((Button) v).getText().toString();
                getKeyboard(num);
                break;
        }
    }
    };

    public void mMath(String str){
    FirstNum = Float.parseFloat(screen.getText().toString());
    operation = str;
    screen.setText("");
    }

    public void getKeyboard(String str){
    String CurrentScreen = screen.getText().toString();
    if(CurrentScreen.equals("0"))
        CurrentScreen = "";
    CurrentScreen = CurrentScreen + str;
    screen.setText(CurrentScreen);
    String ExScreen = CurrentScreen;
    screen.setText(ExScreen);
    }

    public void mResult(){
    float SecondNum = Float.parseFloat(screen.getText().toString());
    float ThirdNum = Float.parseFloat(screen.getText().toString());
    float result = 0;
    //float exresult = result;

    if(operation.equals("+")){
        result = FirstNum + SecondNum;
       // exresult = result + ThirdNum;
    }
    if(operation.equals("-")){
        result = FirstNum - SecondNum;
        //exresult = result - ThirdNum;
    }
    if(operation.equals("*")){
        result = FirstNum * SecondNum;
        //exresult = result * ThirdNum;
    }
    if(operation.equals("/")){
        result = FirstNum / SecondNum;
        //exresult = result / ThirdNum;
    }
    screen.setText(String.valueOf(result));
    //screen.setText(String.valueOf(exresult));
    showtext.setText(String.valueOf(FirstNum + operation + SecondNum));
    //showtext.setText(String.valueOf(FirstNum + operation + SecondNum +           
    operation + ThirdNum));
   }
   }