
com.marvinlabs.widget.floatinglabel.instantpicker.JavaDatePrinter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-floatinglabel-widgets Show documentation
Show all versions of android-floatinglabel-widgets Show documentation
A set of input widgets to show a floating label when not empty.
The newest version!
package com.marvinlabs.widget.floatinglabel.instantpicker;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* A default implementation using the java.util.DateFormat class with the default locale
*/
public class JavaDatePrinter implements DatePrinter {
final DateFormat dateFormat;
/**
* Constructor
*
* @param dateStyle one of DateFormat's SHORT, MEDIUM, LONG, FULL, or DEFAULT.
*/
public JavaDatePrinter(int dateStyle) {
this.dateFormat = DateFormat.getDateInstance(dateStyle);
}
@Override
public String print(DateInstant dateInstant) {
if (dateInstant == null) return "";
Calendar cal = new GregorianCalendar(dateInstant.getYear(), dateInstant.getMonthOfYear() + 1, dateInstant.getDayOfMonth());
return dateFormat.format(cal.getTime());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy