DateUtils
has 22 methods (exceeds 20 allowed). Consider refactoring.
public class DateUtils implements Converter<String, Date> {
public static final String FULL_TIME_PATTERN = "yyyyMMddHHmmss";
public static final String FULL_TIME_SPLIT_PATTERN = "yyyy-MM-dd HH:mm:ss";
public static final String CST_TIME_PATTERN = "EEE MMM dd HH:mm:ss zzz yyyy";
Method parseStringToLong
has 43 lines of code (exceeds 25 allowed). Consider refactoring.
@ExceptionZero
public static long parseStringToLong(String dateStr) {
dateStr = dateStr.trim();
Calendar cal = Calendar.getInstance();
if (dateStr.length() == 19 || dateStr.length() == 23) {
Method parseStringToLong
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
@ExceptionZero
public static long parseStringToLong(String dateStr) {
dateStr = dateStr.trim();
Calendar cal = Calendar.getInstance();
if (dateStr.length() == 19 || dateStr.length() == 23) {
Avoid too many return
statements within this method.
return new Date();
Avoid too many return
statements within this method.
return (cal.getTime().getTime());
Avoid too many return
statements within this method.
return (cal.getTime().getTime());
Avoid too many return
statements within this method.
return parseDate(source, FOR_MARTS.get(0));
Method convert
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
@Override
public Date convert(String source) {
String value = source.trim();
if (StringUtils.EMPTY.equals(value)) {
return new Date();
Similar blocks of code found in 2 locations. Consider refactoring.
} else if (dateStr.length() == 14) {
cal.set(Integer.parseInt(dateStr.substring(0, 4)),
Integer.parseInt(dateStr.substring(4, 6)) - 1,
Integer.parseInt(dateStr.substring(6, 8)),
Integer.parseInt(dateStr.substring(8, 10)),
src/main/java/org/starrier/common/utils/DateUtils.java on lines 248..258 Similar blocks of code found in 2 locations. Consider refactoring.
if (dateStr.length() == 19 || dateStr.length() == 23) {
cal.set(Integer.parseInt(dateStr.substring(0, 4)),
Integer.parseInt(dateStr.substring(5, 7)) - 1,
Integer.parseInt(dateStr.substring(8, 10)),
src/main/java/org/starrier/common/utils/DateUtils.java on lines 266..275 Similar blocks of code found in 2 locations. Consider refactoring.
public static long getDayEndTime(String date) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(parseStringToLong(date));
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.SECOND, 59);
src/main/java/org/starrier/common/utils/DateUtils.java on lines 193..201 Similar blocks of code found in 2 locations. Consider refactoring.
public static long getDayStartTime(String date) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(parseStringToLong(date));
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.SECOND, 0);
src/main/java/org/starrier/common/utils/DateUtils.java on lines 211..219 Similar blocks of code found in 2 locations. Consider refactoring.
} else if (dateStr.length() == 10 || dateStr.length() == 11) {
cal.set(Integer.parseInt(dateStr.substring(0, 4)),
Integer.parseInt(dateStr.substring(5, 7)) - 1,
Integer.parseInt(dateStr.substring(8, 10)), 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
src/main/java/org/starrier/common/utils/DateUtils.java on lines 281..287 Similar blocks of code found in 2 locations. Consider refactoring.
} else if (dateStr.length() == 8) {
cal.set(Integer.parseInt(dateStr.substring(0, 4)),
Integer.parseInt(dateStr.substring(4, 6)) - 1,
Integer.parseInt(dateStr.substring(6, 8)), 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
src/main/java/org/starrier/common/utils/DateUtils.java on lines 275..281 There are no issues that match your filters.