Skip to content

Commit

Permalink
LDEV-5160 fix string bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Nov 15, 2024
1 parent 975fe3d commit c47b153
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions core/src/main/java/lucee/commons/date/JREDateTimeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,20 @@ public String toString(PageContext pc, DateTime dt, TimeZone tz, Boolean addTime
String sb = new String();

sb = sb + "{ts '";
toString(sb, c.get(Calendar.YEAR), 4);
sb = toString(sb, c.get(Calendar.YEAR), 4);
sb = sb + "-";
toString(sb, c.get(Calendar.MONTH) + 1, 2);
sb = toString(sb, c.get(Calendar.MONTH) + 1, 2);
sb = sb + "-";
toString(sb, c.get(Calendar.DATE), 2);
sb = toString(sb, c.get(Calendar.DATE), 2);
sb = sb + " ";
toString(sb, c.get(Calendar.HOUR_OF_DAY), 2);
sb = toString(sb, c.get(Calendar.HOUR_OF_DAY), 2);
sb = sb + ":";
toString(sb, c.get(Calendar.MINUTE), 2);
sb = toString(sb, c.get(Calendar.MINUTE), 2);
sb = sb + ":";
toString(sb, c.get(Calendar.SECOND), 2);
sb = toString(sb, c.get(Calendar.SECOND), 2);
if (addTimeZoneOffset != Boolean.FALSE) {
if (addTimeZoneOffset == null && pc != null) addTimeZoneOffset = ((PageContextImpl) pc).getTimestampWithTSOffset();
if (addTimeZoneOffset == Boolean.TRUE) addTimeZoneOffset(c, sb);
if (addTimeZoneOffset == Boolean.TRUE) sb = addTimeZoneOffset(c, sb);
}
sb = sb + "'}";

Expand All @@ -243,7 +243,7 @@ public String toString(PageContext pc, DateTime dt, TimeZone tz, Boolean addTime
* print.e(c.getTimeZone().getOffset(c.getTimeInMillis())); }
*/

private void addTimeZoneOffset(Calendar c, String sb) {
private String addTimeZoneOffset(Calendar c, String sb) {
int min = (c.get(Calendar.ZONE_OFFSET) + c.get(Calendar.DST_OFFSET)) / 60000;
char op;
if (min < 0) {
Expand All @@ -255,9 +255,9 @@ private void addTimeZoneOffset(Calendar c, String sb) {
int hours = min / 60;
min = min - (hours * 60);
sb = sb + op;
toString(sb, hours, 2);
sb = toString(sb, hours, 2);
sb = sb + ':';
toString(sb, min, 2);
return toString(sb, min, 2);
}

public static Calendar newInstance(TimeZone tz, Locale l) {
Expand Down Expand Up @@ -335,14 +335,14 @@ static void toString(StringBuilder sb, int i, int amount) {
sb.append(str);
}

private static void toString(String sb, int i, int amount) {
private static String toString(String sb, int i, int amount) {
String str = Caster.toString(i);

amount = amount - str.length();
while (amount-- > 0) {
sb = sb + "0";
}
sb = sb + str;
return sb + str;
}


Expand Down

0 comments on commit c47b153

Please sign in to comment.