本文整理汇总了Java中java.time.ZonedDateTime.getMonthValue方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.getMonthValue方法的具体用法?Java ZonedDateTime.getMonthValue怎么用?Java ZonedDateTime.getMonthValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.ZonedDateTime
的用法示例。
在下文中一共展示了ZonedDateTime.getMonthValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeAsHex
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static String encodeAsHex(LocalDateTime dateTime) {
ZonedDateTime zonedDateTime = dateTime.atZone(ZoneOffset.UTC);
byte[] bytes = new byte[5];
bytes[0] = (byte) (zonedDateTime.getYear() - 2000);
bytes[1] = (byte) (zonedDateTime.getMonthValue());
bytes[2] = (byte) (zonedDateTime.getDayOfMonth());
bytes[3] = (byte) (zonedDateTime.getHour());
bytes[4] = (byte) (zonedDateTime.getMinute());
return Hex.encodeHexString(bytes);
}
示例2: render
import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
*
*/
@Override
public void render(XCalendarFrame frame) {
// Background
final GC gc = frame.getGc();
final boolean hovered = mouse.isEntered();
final XCalendarModel model = popup.getModel();
final XCalendarTheme theme = model.getTheme();
final XVirtualCalendar calendar = model.getCalendar();
ZoneId zoneId = model.getZoneId();
final int year = calendar.getYear();
final int month = query(calendar, zoneId, col, row);
final ZonedDateTime d2 = calendar.getTravelDateTime();
final ZonedDateTime d1 = calendar.getCalendarDateTime();
boolean selected = isSameYear(d1, d2) && month == d1.getMonthValue();
this.enabled = isValidYearMonth(year, month, zoneId, calendar::isValid);
int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
gc.setBackground(theme.getBackground(enabled, selected, false, hovered));
gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());
// Foreground
String text = theme.getMonthTheme()[row][col];
gc.setForeground(theme.getForeground(enabled, selected, true));
gc.setFont(theme.getFont()); final Point size = extent(gc, text);
gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1));
}
示例3: isEqual
import java.time.ZonedDateTime; //导入方法依赖的package包/类
private static boolean isEqual(LocalDateTime ldt, Timestamp ts) {
ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
return zdt.getYear() == ts.getYear() + 1900 &&
zdt.getMonthValue() == ts.getMonth() + 1 &&
zdt.getDayOfMonth() == ts.getDate() &&
zdt.getHour() == ts.getHours() &&
zdt.getMinute() == ts.getMinutes() &&
zdt.getSecond() == ts.getSeconds() &&
zdt.getNano() == ts.getNanos();
}
示例4: convertDateIntoYears
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static int convertDateIntoYears(String date) {
String year = date.substring(0, 4);
String month = date.substring(5, 7);
String day = date.substring(8, 10);
ZonedDateTime a = ZonedDateTime.now();
Date newDate = new Date(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
Date newDate1 = new Date(a.getYear(), a.getMonthValue(), a.getDayOfMonth());
long time = newDate1.getTime() - newDate.getTime();
int years = (int) ((time / (1000 * 60 * 60 * 24)) / 31 / 12);
return years;
}
示例5: zonedDateTimeToDateValue
import java.time.ZonedDateTime; //导入方法依赖的package包/类
static DateValue zonedDateTimeToDateValue(ZonedDateTime dt) {
return new DateTimeValueImpl(
dt.getYear(), dt.getMonthValue(), dt.getDayOfMonth(),
dt.getHour(), dt.getMinute(), dt.getSecond());
}