get Chinese Leap Month Days - Android Internationalization

Android examples for Internationalization:Chinese

Description

get Chinese Leap Month Days

Demo Code


//package com.java2s;

public class Main {
    private final static byte[] lunarCalendarSpecialInfo = new byte[] {
            0x08, 0x00, 0x00, 0x05, 0x00, 0x00, 0x14, 0x00, 0x00, 0x02,
            0x00, 0x06, 0x00, 0x00, 0x15, 0x00, 0x00, 0x02, 0x00, 0x17,
            0x00, 0x00, 0x05, 0x00, 0x00, 0x14, 0x00, 0x00, 0x02, 0x00,
            0x06, 0x00, 0x00, 0x05, 0x00, 0x00, 0x13, 0x00, 0x17, 0x00,
            0x00, 0x16, 0x00, 0x00, 0x14, 0x00, 0x00, 0x02, 0x00, 0x07,
            0x00, 0x00, 0x15, 0x00, 0x00, 0x13, 0x00, 0x08, 0x00, 0x00,
            0x06, 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x07, 0x00,
            0x00, 0x05, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x16,
            0x00, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x06, 0x00, 0x00,
            0x05, 0x00, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x05, 0x00,
            0x00, 0x04, 0x00, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x05,
            0x00, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x16, 0x00, 0x00,
            0x04, 0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x05, 0x00,
            0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x16, 0x00, 0x00, 0x05,
            0x00, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x15, 0x00, 0x00 };
    private final static int baseYear = 1900;
    private final static int bigMonthDays = 30;
    private final static int smallMonthDays = 29;

    final public static int getLeapMonthDays(int lunarYear) {
        if (getLeapMonth(lunarYear) == 0)
            return 0;
        else if ((lunarCalendarSpecialInfo[lunarYear - baseYear] & 0x10) != 0)
            return bigMonthDays;
        else/*from   w ww .j a  v  a  2 s  .  c  o  m*/
            return smallMonthDays;
    }

    final public static int getLeapMonth(int lunarYear) {
        return lunarCalendarSpecialInfo[lunarYear - baseYear] & 0xf;
    }
}

Related Tutorials