dayOfProgrammer American time machine test

-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

 

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;     } }

 

 

 

 #牛客AI配图神器#

#你的房租占工资的比例是多少?##找实习你看重大厂光环还是业务方向##牛客创作赏金赛##考研对你找工作产生了哪些影响?##你最满意的offer薪资是哪家公司?#
Java技术 文章被收录于专栏

JavaEE技术 编程开发经验 企业通用技术

全部评论

相关推荐

头像
今天 20:19
已编辑
门头沟学院 人工智能
本文略长,献给身处双非、学院本科的低年级依旧陷入迷茫的同学,一个参考。夹杂强烈主观因素,若观点不同,仅当笑料。近日,工作之余的午休时间给母校的学弟学妹进行了宣讲,同时也接受了牛客的访谈,不约而同的触发了两个关键词考研,就业。现象今年和去年,认识的学弟学妹,来自知某、抖某、牛客等系列的学弟学妹,这次宣讲,约有20个学弟学妹来加了我的联系方式,向我取经,聊聊未来,聊聊想法。我这里简单概括一下。1.现在很迷茫,大方向摇摆就业还是考研,但是倾向考研。小方向摇摆竞赛和项目,不知道怎么去做,不知道怎么开始。2.考研的直接目的绝大多数都是为了(混)学历,根本目的就是提高就业竞争力。3.我把他们都拉了个群,在...
牛客85294058...:“私聊能够滔滔不绝,而拉了一个小群之后就完全一声不吭”个人观点这跟从小到大“不要浪费大家时间”的社会环境有关:个人化的提问,如果你上学时有留心、或者参加QA环节多,会注意到这种做法经常是被人骂的。要营造让大家开口的氛围和做出欢迎讨论的议题设置还是比较难的,期待方法探索。
投递大连飞创信息技术有限公司等公司10个岗位
点赞 评论 收藏
分享
09-29 16:59
已编辑
门头沟学院 Java
牛客96609213...:疯狂背刺,之前还明确设置截止日期,还有笔试,现在一帮人卡在复筛,他反而一边开启扩招,还给扩招的免笔试,真服了,你好歹先把复筛中的给处理了再说
投递大疆等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务