{"record":{"id":"ca11b56674dfb45a","repo":"chinabugotech/hutool","slug":"seconds-must-be-a-positive-number","errorCode":null,"errorMessage":"Seconds must be a positive number!","messagePattern":"Seconds must be a positive number!","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java","lineNumber":1969,"sourceCode":"\n\t\tint result = 0;\n\t\tfor (int i = lastIndex; i >= 0; i--) {\n\t\t\tresult += Integer.parseInt(hms.get(i)) * Math.pow(60, (lastIndex - i));\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * 秒数转为时间格式(HH:mm:ss)<br>\n\t * 参考：<a href=\"https://github.com/iceroot\">https://github.com/iceroot</a>\n\t *\n\t * @param seconds 需要转换的秒数\n\t * @return 转换后的字符串\n\t * @since 3.1.2\n\t */\n\tpublic static String secondToTime(int seconds) {\n\t\tif (seconds < 0) {\n\t\t\tthrow new IllegalArgumentException(\"Seconds must be a positive number!\");\n\t\t}\n\n\t\tint hour = seconds / 3600;\n\t\tint other = seconds % 3600;\n\t\tint minute = other / 60;\n\t\tint second = other % 60;\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tif (hour < 10) {\n\t\t\tsb.append(\"0\");\n\t\t}\n\t\tsb.append(hour);\n\t\tsb.append(\":\");\n\t\tif (minute < 10) {\n\t\t\tsb.append(\"0\");\n\t\t}\n\t\tsb.append(minute);\n\t\tsb.append(\":\");\n\t\tif (second < 10) {","sourceCodeStart":1951,"sourceCodeEnd":1987,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java#L1951-L1987","documentation":"Error \"Seconds must be a positive number!\" thrown in chinabugotech/hutool.","triggerScenarios":"Thrown at hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java:1969 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a positive number of seconds; validate the argument before the call.","Use Math.max(1, seconds) if a non-positive value may flow in."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}