正如我在标题中提到的那样尝试修复此错误,但无法弄清楚。我没有比较任何东西为什么我得到这个我不知道。我试图将字符串更改为浮动但没有成功。也许我应该改变 StringTools 但不确定用什么代替它。
package com.bykd.output;
@:final class DateOutput
{
public static inline var HOUR : String = "%h";
public static inline var MONTH : String = "%m";
public static inline var SECOND : String = "%s";
public static inline var MINUTE : String = "%i";
public static inline var DAY : String = "%d";
public static inline var YEAR : String = "%y";
public function new()
{
//super();
}
public static function formatDate(date : Date, format : String) : String
{
var output : String = null;
output = format;
output = StringTools.replace(output, DAY, leadZero(date.getDay));
output = StringTools.replace(output, MONTH, leadZero(date.getMonth));
output = StringTools.replace(output, YEAR, date.getFullYear);
return output;
}
public static function formatTime(date : Date, format : String) : String
{
var output : String = null;
output = format;
output = StringTools.replace(output, HOUR, leadZero(date.getHours));
output = StringTools.replace(output, MINUTE, leadZero(date.getMinutes));
output = StringTools.replace(output, SECOND, leadZero(date.getSeconds));
return output;
}
public static function leadZero(num : Float) : String
{
return Std.string("00" + num).substr(-2, 2);
}
}