Skip to content

Commit 2aaf86a

Browse files
committed
Replace string for constant.
1 parent a37fd5f commit 2aaf86a

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/main/java/com/cronutils/descriptor/TimeDescriptionStrategy.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class TimeDescriptionStrategy extends DescriptionStrategy {
3939
private static final String EVERY = "every";
4040
private static final String SECOND = "second";
4141
private static final String MINUTE = "minute";
42+
private static final String HOUR = "hour";
4243
private static final String EVERY_MINUTE_FORMAT = "%s %s ";
4344

4445
/**
@@ -90,7 +91,7 @@ public String describe() {
9091
}
9192
String secondsDesc = "";
9293
String minutesDesc = "";
93-
final String hoursDesc = addTimeExpressions(describe(hours), bundle.getString("hour"),
94+
final String hoursDesc = addTimeExpressions(describe(hours), bundle.getString(HOUR),
9495
bundle.getString("hours"));
9596
if (!(seconds instanceof On && isDefault((On) seconds))) {
9697
secondsDesc = addTimeExpressions(describe(seconds), bundle.getString(SECOND), bundle.getString("seconds"));
@@ -135,13 +136,13 @@ private void registerFunctions() {
135136
&& timeFields.seconds instanceof On) {
136137
if (TimeDescriptionStrategy.this.isDefault((On) timeFields.seconds)) {
137138
if (TimeDescriptionStrategy.this.isDefault((On) timeFields.minutes)) {
138-
return String.format(EVERY_MINUTE_FORMAT, bundle.getString(EVERY), bundle.getString("hour"));
139+
return String.format(EVERY_MINUTE_FORMAT, bundle.getString(EVERY), bundle.getString(HOUR));
139140
}
140-
return String.format("%s %s %s %s %s", bundle.getString(EVERY), bundle.getString("hour"),
141+
return String.format("%s %s %s %s %s", bundle.getString(EVERY), bundle.getString(HOUR),
141142
bundle.getString("at"), bundle.getString(MINUTE),
142143
((On) timeFields.minutes).getTime().getValue());
143144
} else {
144-
return String.format("%s %s %s %s %s %s %s %s", bundle.getString(EVERY), bundle.getString("hour"),
145+
return String.format("%s %s %s %s %s %s %s %s", bundle.getString(EVERY), bundle.getString(HOUR),
145146
bundle.getString("at"), bundle.getString(MINUTE),
146147
((On) timeFields.minutes).getTime().getValue(), bundle.getString("and"),
147148
bundle.getString(SECOND), ((On) timeFields.seconds).getTime().getValue());
@@ -239,7 +240,7 @@ private void registerFunctions() {
239240
&& ((On) timeFields.seconds).getTime().getValue() == 0) {
240241
final Integer period = ((Every) timeFields.hours).getPeriod().getValue();
241242
if (period == null || period == 1) {
242-
return String.format(EVERY_MINUTE_FORMAT, bundle.getString(EVERY), bundle.getString("hour"));
243+
return String.format(EVERY_MINUTE_FORMAT, bundle.getString(EVERY), bundle.getString(HOUR));
243244
}
244245
}
245246
final String result = String.format("%s %s %s %s %s %s ", bundle.getString(EVERY),
@@ -286,7 +287,7 @@ private void registerFunctions() {
286287
if (timeFields.hours instanceof And && timeFields.minutes instanceof Always && timeFields.seconds instanceof Always) {
287288
// Every
288289
String hoursDesc = addTimeExpressions(describe(timeFields.hours),
289-
bundle.getString("hour"), bundle.getString("hours"));
290+
bundle.getString(HOUR), bundle.getString("hours"));
290291
return String.format("%s %s %s", bundle.getString(EVERY), bundle.getString(SECOND), hoursDesc);
291292
}
292293
return StringUtils.EMPTY;

0 commit comments

Comments
 (0)