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技术 编程开发经验 企业通用技术

全部评论

相关推荐

门口唉提是地铁杀:之前b站被一个游戏demo深深的吸引了。看up主页发现是个初创公司,而且还在招人,也是一天60。二面的时候要我做一个登录验证和传输文件两个微服务,做完要我推到github仓库,还要我加上jaeger和一堆运维工具做性能测试并且面试的时候投屏演示。我傻乎乎的做完以后人家跟我说一句现在暂时不招人,1分钱没拿到全是白干
你的秋招第一场笔试是哪家
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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