Java Code Examples for java.time.ZonedDateTime#getMonth()

The following examples show how to use java.time.ZonedDateTime#getMonth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZonedDateTimeAxis.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
protected String getTickMarkLabel(ZonedDateTime datetime) {
    final StringConverter<ZonedDateTime> converter = getTickLabelFormatter();
    if (converter != null) {
        return converter.toString(datetime);
    }

    final DateTimeFormatter formatter;
    if (actualInterval.interval == ChronoUnit.YEARS && datetime.getMonth() == Month.JANUARY && datetime.getDayOfMonth() == 1) {
        formatter = DateTimeFormatter.ofPattern("yyyy");
    } else if (actualInterval.interval == ChronoUnit.MONTHS && datetime.getDayOfMonth() == 1) {
        formatter = DateTimeFormatter.ofPattern("MMM yy");
    } else {
        switch (actualInterval.interval) {
            case DAYS:
            case WEEKS:
            case HOURS:
            case MINUTES:
                formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
                break;
            case SECONDS:
                formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
                break;
            case MILLIS:
                formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL);
                break;
            default:
                formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
                break;
        }
    }
    return formatter.format(datetime);
}
 
Example 2
Source File: TestTime.java    From webtau with Apache License 2.0 4 votes vote down vote up
public static TestTime today(Integer hours, Integer minutes) {
    ZonedDateTime now = LocalDateTime.now().atZone(UTC);
    return new TestTime(now.getYear(), now.getMonth(), now.getDayOfMonth(), hours, minutes, 0);
}
 
Example 3
Source File: MonthFunction.java    From vertexium with Apache License 2.0 4 votes vote down vote up
@Override
protected Object invokeZonedDateTime(VertexiumCypherQueryContext ctx, ZonedDateTime date) {
    return date.getMonth();
}