mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-09 04:11:50 +01:00
Fixed datetime format 00:00:43 #345
This commit is contained in:
parent
c3b2afbf36
commit
765e1bb54d
@ -94,48 +94,72 @@ public class FormatUtils {
|
|||||||
long hours = x % 24;
|
long hours = x % 24;
|
||||||
x /= 24;
|
x /= 24;
|
||||||
long days = x % 365;
|
long days = x % 365;
|
||||||
|
long months = days % 30;
|
||||||
|
days -= months * 30;
|
||||||
x /= 365;
|
x /= 365;
|
||||||
long years = x;
|
long years = x;
|
||||||
|
|
||||||
|
String fYear = Settings.FORMAT_YEAR.toString();
|
||||||
|
String fYears = Settings.FORMAT_YEARS.toString();
|
||||||
|
String fMonth = Settings.FORMAT_MONTH.toString();
|
||||||
|
String fMonths = Settings.FORMAT_MONTHS.toString();
|
||||||
|
String fDay = Settings.FORMAT_DAY.toString();
|
||||||
|
String fDays = Settings.FORMAT_DAYS.toString();
|
||||||
|
String fHours = Settings.FORMAT_HOURS.toString();
|
||||||
|
String fMinutes = Settings.FORMAT_MINUTES.toString();
|
||||||
|
String fSeconds = Settings.FORMAT_SECONDS.toString();
|
||||||
|
|
||||||
if (years != 0) {
|
if (years != 0) {
|
||||||
if (years == 1) {
|
if (years == 1) {
|
||||||
builder.append(Settings.FORMAT_YEAR.toString());
|
builder.append(fYear);
|
||||||
} else {
|
} else {
|
||||||
builder.append(Settings.FORMAT_YEARS.toString().replace("%years%", String.valueOf(years)));
|
builder.append(fYears.replace("%years%", String.valueOf(years)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (months != 0) {
|
||||||
|
if (months == 1) {
|
||||||
|
builder.append(fMonth);
|
||||||
|
} else {
|
||||||
|
builder.append(fMonths.replace("%months%", String.valueOf(months)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (days != 0) {
|
if (days != 0) {
|
||||||
if (days == 1) {
|
if (days == 1) {
|
||||||
builder.append(Settings.FORMAT_DAY.toString());
|
builder.append(fDay);
|
||||||
} else {
|
} else {
|
||||||
builder.append(Settings.FORMAT_DAYS.toString().replace("%days%", String.valueOf(days)));
|
builder.append(fDays.replace("%days%", String.valueOf(days)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hours != 0) {
|
if (hours != 0) {
|
||||||
String h = Settings.FORMAT_HOURS.toString().replace("%hours%", String.valueOf(hours));
|
String h = fHours.replace("%hours%", String.valueOf(hours));
|
||||||
if (h.contains("%zero%") && String.valueOf(hours).length() == 1) {
|
if (h.contains("%zero%") && String.valueOf(hours).length() == 1) {
|
||||||
builder.append('0');
|
builder.append('0');
|
||||||
}
|
}
|
||||||
builder.append(h);
|
builder.append(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minutes != 0) {
|
if (minutes != 0) {
|
||||||
String m = Settings.FORMAT_MINUTES.toString().replace("%minutes%", String.valueOf(minutes));
|
String m = fMinutes.replace("%minutes%", String.valueOf(minutes));
|
||||||
if (hours == 0 && m.contains("%hours%")) {
|
if (hours == 0 && m.contains("%hours%")) {
|
||||||
m = m.replace("%hours%", Settings.FORMAT_MINUTES.toString().replace("%zero%", "0") + "0");
|
builder.append(fHours.replace("%zero%", "0").replace("%hours%", "0"));
|
||||||
} else {
|
m = m.replace("%hours%", "");
|
||||||
m = m.replace("%hours", "");
|
|
||||||
}
|
}
|
||||||
|
m = m.replace("%hours%", "");
|
||||||
if (m.contains("%zero%") && String.valueOf(minutes).length() == 1) {
|
if (m.contains("%zero%") && String.valueOf(minutes).length() == 1) {
|
||||||
builder.append('0');
|
builder.append('0');
|
||||||
}
|
}
|
||||||
builder.append(m);
|
builder.append(m);
|
||||||
}
|
}
|
||||||
if (seconds != 0) {
|
if (seconds != 0) {
|
||||||
String s = Settings.FORMAT_SECONDS.toString().replace("%seconds%", String.valueOf(seconds));
|
String s = fSeconds.replace("%seconds%", String.valueOf(seconds));
|
||||||
if (minutes == 0 && s.contains("%minutes%")) {
|
if (minutes == 0 && s.contains("%minutes%")) {
|
||||||
s = s.replace("%minutes%", Settings.FORMAT_MINUTES.toString().replace("%hours", "").replace("%zero%", "0") + 0);
|
if (hours == 0 && fMinutes.contains("%hours%")) {
|
||||||
} else {
|
builder.append(fHours.replace("%zero%", "0").replace("%hours%", "0"));
|
||||||
s = s.replace("%minutes%", "");
|
}
|
||||||
|
builder.append(fMinutes.replace("%hours%", "").replace("%zero%", "0").replace("%minutes%", "0"));
|
||||||
}
|
}
|
||||||
|
s = s.replace("%minutes%", "");
|
||||||
if (s.contains("%zero%") && String.valueOf(seconds).length() == 1) {
|
if (s.contains("%zero%") && String.valueOf(seconds).length() == 1) {
|
||||||
builder.append('0');
|
builder.append('0');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user