Example usage for java.time YearMonth getMonthValue

List of usage examples for java.time YearMonth getMonthValue

Introduction

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

Prototype

public int getMonthValue() 

Source Link

Document

Gets the month-of-year field from 1 to 12.

Usage

From source file:Main.java

public static void main(String[] args) {
    YearMonth y = YearMonth.now();
    int m = y.getMonthValue();
    System.out.println(m);//from ww w .j  a  v a 2  s .c o  m

}

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 a  v a2s. c o m
    }
    return StringUtils.EMPTY;
}