-CoderOilStation

 

TCS needs 2025/06/14

 

dayOfProgrammer
* American time machine test on the Russia Calendar
* return 256th day of programmer day
* exists two type calendar
* Julian Calendar
* Gregorian Calendar
* output
* that day by using simple date format dd.mm.yyy
* constriants:
* 1700<=year<=2700
* 1918 year is a special year
* the 32th day January is February 14th this year and this month is beging with 14th day
* from 1700 to 1917 using Julian Calendar
* from 1919 to 2700 using Gregorian Calendar

 

/**
     * dayOfProgrammer
     * American time machine test on the Russia Calendar
     * return 256th day of programmer day
     * exists two type calendar
     * Julian Calendar
     * Gregorian Calendar
     * output
     * that day by using simple date format dd.mm.yyy
     * constriants:
     * 1700<=year<=2700
     * 1918 year is a special year
     * the 32th day January is February 14th this year and this month is beging with 14th day
     * from 1700 to 1917 using Julian Calendar
     * from 1919 to 2700 using Gregorian Calendar
     *
     * @param year
     * @return
     */
   
public static String dayOfProgrammer(int year) {
        if (year < 1700 || year > 2700) {
            return null;
        }
//        if ()
       
return null;
    }

    /**
     * get day of programmer by using Russia Gregorian Calendar
     * 256th day of programmer in this input year
     * @param year
     * @return
     */
   
public static String dayOfProgrammerGregorian(int year) {
        if (!checkIsGregorianYear(year)) {
            return null;
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(year);
        if (checkIsLeapYear(year)) {
            // Jan31 Feb29 March31 April30 May31 June30 July31 August31 Sept30 Octor31 Norve30 Decem31
           
int yearWhichMonth = CalendarConstant.WHICHDAYOFPROGRAMMER / 29;
            if(yearWhichMonth==GregorianCalendarMonthEnum.JAN.getMonthVal()){
                stringBuilder.append(GregorianCalendarMonthEnum.JAN.getKey());
            }else if(yearWhichMonth==GregorianCalendarMonthEnum.FEB.getMonthVal()){
                stringBuilder.append(GregorianCalendarMonthEnum.JAN.getKey());
            }else if(yearWhichMonth==GregorianCalendarMonthEnum.MAR.getMonthVal()){
                stringBuilder.append(GregorianCalendarMonthEnum.JAN.getKey());
            }else if(yearWhichMonth==GregorianCalendarMonthEnum.APR.getMonthVal()){
                stringBuilder.append(GregorianCalendarMonthEnum.JAN.getKey());
            }else if(yearWhichMonth==GregorianCalendarMonthEnum.MAY.getMonthVal()){
                stringBuilder.append(GregorianCalendarMonthEnum.JAN.getKey());
            }else if(yearWhichMonth==GregorianCalendarMonthEnum.JUN.getMonthVal()){
                stringBuilder.append(GregorianCalendarMonthEnum.JAN.getKey());
            }else if(yearWhichMonth==GregorianCalendarMonthEnum.JUL.getMonthVal()){
                stringBuilder.append(GregorianCalendarMonthEnum.JAN.getKey());
            } else if(yearWhichMonth==GregorianCalendarMonthEnum.AUG.getMonthVal()){
                stringBuilder.append(GregorianCalendarMonthEnum.JAN.getKey());
            }else if(yearWhichMonth==GregorianCalendarMonthEnum.SEP.getMonthVal()){
                stringBuilder.append(GregorianCalendarMonthEnum.JAN.getKey());
            } else if (yearWhichMonth==GregorianCalendarMonthEnum.OCT.getMonthVal()) {

            } else if (yearWhichMonth==GregorianCalendarMonthEnum.NOV.getMonthVal()) {

            } else if (yearWhichMonth==GregorianCalendarMonthEnum.DEC.getMonthVal()) {

            }
        }


        return null;
    }

    /**
     * check year if is leap year
     *
     * @param year
     * @return
     */
   
public static Boolean checkIsLeapYear(int year) {
        if (year < 1700 || year > 2700) {
            return null;
        }
        if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
            return true;
        }
        return false;
    }

    /**
     * check year if it is Russia Julian Calendar
     *
     * @param year
     * @return
     */
   
public static Boolean checkIsJulianYear(int year) {
        if (year < 1700 || year > 2700) {
            return null;
        }
        if (year >= 1700 && year <= 1917) {
            return true;
        }
        return false;
    }

    /**
     * check year if it is Russia Greborian Calendar
     *
     * @param year
     * @return
     */
   
public static Boolean checkIsGregorianYear(int year) {
        if (year < 1700 || year > 2700) {
            return null;
        }
        if (year > 1918 && year <= 2700) {
            return true;
        }
        return false;
    }

    /**
     * check year if it is Russia special transmition year
     *
     * @param year
     * @return
     */
   
public static Boolean checkIsRussiaSpecialTransitionYear(int year) {
        if (year < 1700 || year > 2700) {
            return null;
        }
        if (year == 1918) {
            return true;
        }
        return false;
    }

 

package tcs.com.utils.constant;

public class CalendarConstant {
    public static final int GREGORIANLEAPYEARTOTALDAYS=366;
    public static final int GREGORIANNOTLEAPYEARTOTALDAYS=365;
    public static final int WHICHDAYOFPROGRAMMER=256;
}

 

package tcs.com.utils.enumration;

public enum GregorianCalendarMonthEnum {
    JAN("JAN","1月",1),
    FEB("FEB","2月",2),
    MAR("MAR","3月",3),
    APR("APR","4月",4),
    MAY("MAY","5月",5),
    JUN("JUN","6月",6),
    JUL("JUL","7月",7),
    AUG("AUG","8月",8),
    SEP("SEP","9月",9),
    OCT("OCT","10月",10),
    NOV("NOV","11月",11),
    DEC("DEC","12月",12)
    ;
    private String key;
    private String value;
    private Integer monthVal;
    private GregorianCalendarMonthEnum(String key, String value, Integer monthVal) {
        this.key = key;
        this.value = value;
        this.monthVal = monthVal;
    }
    public String getKey(){
        return this.key;
    }
    public String getValue(){
        return this.value;
    }

    public Integer getMonthVal(){
        return this.monthVal;
    }


}

 

 

posted on 2025-06-14 17:06  CoderOilStation  阅读(9)  评论(0)    收藏  举报