Example usage for java.time YearMonth getYear

List of usage examples for java.time YearMonth getYear

Introduction

In this page you can find the example usage for java.time YearMonth getYear.

Prototype

public int getYear() 

Source Link

Document

Gets the year field.

Usage

From source file:Main.java

public static void main(String[] args) {
    YearMonth y = YearMonth.now();
    int m = y.getYear();
    System.out.println(m);/*from  ww  w.  j  a v a2s  . c om*/

}

From source file:org.opensingular.form.wicket.mapper.YearMonthMapper.java

@Override
public String getReadOnlyFormattedText(WicketBuildContext ctx, IModel<? extends SInstance> model) {
    if ((model != null) && (model.getObject() != null)) {
        SInstance instancia = model.getObject();
        if (instancia.getValue() instanceof YearMonth) {
            YearMonth ym = (YearMonth) instancia.getValue();
            return String.format("%02d/%04d", ym.getMonthValue(), ym.getYear());
        }//from  w w  w .  j  av a2s .  c om
    }
    return StringUtils.EMPTY;
}