![JAR search and dependency download from the Maven repository](/logo.png)
com.crosstreelabs.phpfunctions.dateformat.DayOfWeekPrinterParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of phpfunctions Show documentation
Show all versions of phpfunctions Show documentation
Provides a selection of PHP's functionality in Java, including date/time formatting.
The newest version!
package com.crosstreelabs.phpfunctions.dateformat;
import java.util.Locale;
import org.joda.time.DateTimeFieldType;
import org.joda.time.ReadablePartial;
public class DayOfWeekPrinterParser extends AbstractPrinterParser {
private final boolean iso;
public DayOfWeekPrinterParser() {
this(true);
}
public DayOfWeekPrinterParser(final boolean iso) {
this.iso = iso;
}
@Override
public String fromPartial(ReadablePartial partial, Locale locale) {
// Surely there's a better way to do this?
int n = partial.get(DateTimeFieldType.dayOfWeek());
if (!iso) {
if (n == 7) {
return 0+"";
}
return ++n+"";
}
return n+"";
}
@Override
public int estimatePrintedLength() {
return 2;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy