Java Code Examples for java.time.LocalTime#getMinute()
The following examples show how to use
java.time.LocalTime#getMinute() .
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: Helper.java From Medusa with Apache License 2.0 | 5 votes |
public static final void drawTimeSections(final Clock CLOCK, final GraphicsContext CTX, final List<TimeSection> SECTIONS, final double SIZE, final double XY_INSIDE, final double XY_OUTSIDE, final double WH_INSIDE, final double WH_OUTSIDE, final double LINE_WIDTH) { if (SECTIONS.isEmpty()) return; TickLabelLocation tickLabelLocation = CLOCK.getTickLabelLocation(); ZonedDateTime time = CLOCK.getTime(); boolean isAM = time.get(ChronoField.AMPM_OF_DAY) == 0; double xy = TickLabelLocation.INSIDE == tickLabelLocation ? XY_INSIDE * SIZE : XY_OUTSIDE * SIZE; double wh = TickLabelLocation.INSIDE == tickLabelLocation ? WH_INSIDE * SIZE : WH_OUTSIDE * SIZE; double offset = 90; int listSize = SECTIONS.size(); double angleStep = 360.0 / 60.0; boolean highlightSections = CLOCK.isHighlightSections(); for (int i = 0 ; i < listSize ; i++) { TimeSection section = SECTIONS.get(i); LocalTime start = section.getStart(); LocalTime stop = section.getStop(); boolean isStartAM = start.get(ChronoField.AMPM_OF_DAY) == 0; boolean isStopAM = stop.get(ChronoField.AMPM_OF_DAY) == 0; boolean draw = isAM ? (isStartAM || isStopAM) :(!isStartAM || !isStopAM); if (draw) { double sectionStartAngle = (start.getHour() % 12 * 5.0 + start.getMinute() / 12.0 + start.getSecond() / 300.0) * angleStep + 180; double sectionAngleExtend = ((stop.getHour() - start.getHour()) % 12 * 5.0 + (stop.getMinute() - start.getMinute()) / 12.0 + (stop.getSecond() - start.getSecond()) / 300.0) * angleStep; //TODO: Add an indicator to the section like -1 or similar // check if start was already yesterday if (start.getHour() > stop.getHour()) { sectionAngleExtend = (360.0 - Math.abs(sectionAngleExtend)); } CTX.save(); if (highlightSections) { CTX.setStroke(section.contains(time.toLocalTime()) ? section.getHighlightColor() : section.getColor()); } else { CTX.setStroke(section.getColor()); } CTX.setLineWidth(SIZE * LINE_WIDTH); CTX.setLineCap(StrokeLineCap.BUTT); CTX.strokeArc(xy, xy, wh, wh, -(offset + sectionStartAngle), -sectionAngleExtend, ArcType.OPEN); CTX.restore(); } } }
Example 2
Source File: TCKLocalizedPrinterParser.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") @Test(dataProvider="time") public void test_time_parse(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) { DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale); Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond()); String text = old.format(oldDate); DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale); TemporalAccessor parsed = f.parse(text, pos); assertEquals(pos.getIndex(), text.length()); assertEquals(pos.getErrorIndex(), -1); assertEquals(LocalTime.from(parsed), time); }
Example 3
Source File: TCKLocalizedPrinterParser.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") @Test(dataProvider="time") public void test_time_print(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) { DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale); Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond()); String text = old.format(oldDate); DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale); String formatted = f.format(time); assertEquals(formatted, text); }
Example 4
Source File: TCKLocalizedPrinterParser.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") @Test(dataProvider="time") public void test_time_print(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) { DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale); Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond()); String text = old.format(oldDate); DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale); String formatted = f.format(time); assertEquals(formatted, text); }
Example 5
Source File: PrayerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
String getEstimatedTimeRemaining(boolean formatForOrb) { final double drainRate = getPrayerDrainRate(client); if (drainRate == 0) { return "N/A"; } final int currentPrayer = client.getBoostedSkillLevel(Skill.PRAYER); // Calculate how many seconds each prayer points last so the prayer bonus can be applied final double secondsPerPoint = (60.0 / drainRate) * (1.0 + (prayerBonus / 30.0)); // Calculate the number of seconds left final double secondsLeft = (currentPrayer * secondsPerPoint); LocalTime timeLeft = LocalTime.ofSecondOfDay((long) secondsLeft); if (formatForOrb && timeLeft.getMinute() > 9) { return timeLeft.format(DateTimeFormatter.ofPattern("m")) + "m"; } else { return timeLeft.format(DateTimeFormatter.ofPattern("m:ss")); } }
Example 6
Source File: TCKLocalizedPrinterParser.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") @Test(dataProvider="time") public void test_time_parse(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) { DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale); Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond()); String text = old.format(oldDate); DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale); TemporalAccessor parsed = f.parse(text, pos); assertEquals(pos.getIndex(), text.length()); assertEquals(pos.getErrorIndex(), -1); assertEquals(LocalTime.from(parsed), time); }
Example 7
Source File: TCKLocalizedPrinterParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") @Test(dataProvider="time") public void test_time_parse(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) { DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale); Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond()); String text = old.format(oldDate); DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale); TemporalAccessor parsed = f.parse(text, pos); assertEquals(pos.getIndex(), text.length()); assertEquals(pos.getErrorIndex(), -1); assertEquals(LocalTime.from(parsed), time); }
Example 8
Source File: TCKLocalizedPrinterParser.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") @Test(dataProvider="time") public void test_time_parse(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) { DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale); Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond()); String text = old.format(oldDate); DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale); TemporalAccessor parsed = f.parse(text, pos); assertEquals(pos.getIndex(), text.length()); assertEquals(pos.getErrorIndex(), -1); assertEquals(LocalTime.from(parsed), time); }
Example 9
Source File: TCKLocalizedPrinterParser.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") @Test(dataProvider="time") public void test_time_print(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) { DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale); Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond()); String text = old.format(oldDate); DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale); String formatted = f.format(time); assertEquals(formatted, text); }
Example 10
Source File: LocalTimeComparator.java From flink with Apache License 2.0 | 5 votes |
public static void putNormalizedKeyLocalTime(LocalTime record, MemorySegment target, int offset, int numBytes) { int hour = record.getHour(); if (numBytes > 0) { target.put(offset, (byte) (hour & 0xff - Byte.MIN_VALUE)); numBytes -= 1; offset += 1; } int minute = record.getMinute(); if (numBytes > 0) { target.put(offset, (byte) (minute & 0xff - Byte.MIN_VALUE)); numBytes -= 1; offset += 1; } int second = record.getSecond(); if (numBytes > 0) { target.put(offset, (byte) (second & 0xff - Byte.MIN_VALUE)); numBytes -= 1; offset += 1; } int nano = record.getNano(); int unsignedNano = nano - Integer.MIN_VALUE; if (numBytes >= 4) { target.putIntBigEndian(offset, unsignedNano); numBytes -= 4; offset += 4; } else if (numBytes > 0) { for (int i = 0; numBytes > 0; numBytes--, i++) { target.put(offset + i, (byte) (unsignedNano >>> ((3 - i) << 3))); } return; } for (int i = 0; i < numBytes; i++) { target.put(offset + i, (byte) 0); } }
Example 11
Source File: JavatimeTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static boolean isEqual(LocalTime lt, java.sql.Time t) { return lt.getHour() == t.getHours() && lt.getMinute() == t.getMinutes() && lt.getSecond() == t.getSeconds(); }
Example 12
Source File: LocalTimeHandle.java From alibaba-rsocket-broker with Apache License 2.0 | 4 votes |
public LocalTimeHandle(LocalTime o) { this.hour = o.getHour(); this.minute = o.getMinute(); this.second = o.getSecond(); this.nano = o.getNano(); }
Example 13
Source File: TimerControlTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
private void drawTimeSections() { if (sectionMap.isEmpty()) return; ZonedDateTime time = tile.getTime(); DayOfWeek day = time.getDayOfWeek(); boolean isAM = time.get(ChronoField.AMPM_OF_DAY) == 0; double offset = 90; double angleStep = 360.0 / 60.0; boolean highlightSections = tile.isHighlightSections(); for (TimeSection section : sectionMap.keySet()) { LocalTime start = section.getStart(); LocalTime stop = section.getStop(); boolean isStartAM = start.get(ChronoField.AMPM_OF_DAY) == 0; boolean isStopAM = stop.get(ChronoField.AMPM_OF_DAY) == 0; boolean draw = isAM ? (isStartAM || isStopAM) : (!isStartAM || !isStopAM); if (!section.getDays().contains(day)) { draw = false; } if (!section.isActive()) { draw = false; } if (draw) { double sectionStartAngle = (start.getHour() % 12 * 5.0 + start.getMinute() / 12.0 + start.getSecond() / 300.0) * angleStep + 180; double sectionAngleExtend = ((stop.getHour() - start.getHour()) % 12 * 5.0 + (stop.getMinute() - start.getMinute()) / 12.0 + (stop.getSecond() - start.getSecond()) / 300.0) * angleStep; if (start.getHour() > stop.getHour()) { sectionAngleExtend = (360.0 - Math.abs(sectionAngleExtend)); } Arc arc = sectionMap.get(section); arc.setCenterX(clockSize * 0.5); arc.setCenterY(clockSize * 0.5); arc.setRadiusX(clockSize * 0.45); arc.setRadiusY(clockSize * 0.45); arc.setStartAngle(-(offset + sectionStartAngle)); arc.setLength(-sectionAngleExtend); arc.setType(ArcType.OPEN); arc.setStrokeWidth(clockSize * 0.04); arc.setStrokeLineCap(StrokeLineCap.BUTT); arc.setFill(null); if (highlightSections) { arc.setStroke(section.contains(time.toLocalTime()) ? section.getHighlightColor() : section.getColor()); } else { arc.setStroke(section.getColor()); } } } }
Example 14
Source File: JavatimeTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private static boolean isEqual(LocalTime lt, java.sql.Time t) { return lt.getHour() == t.getHours() && lt.getMinute() == t.getMinutes() && lt.getSecond() == t.getSeconds(); }
Example 15
Source File: Time.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 2 votes |
/** * Obtains an instance of {@code Time} from a {@link LocalTime} object * with the same hour, minute and second time value as the given * {@code LocalTime}. * * @param time a {@code LocalTime} to convert * @return a {@code Time} object * @exception NullPointerException if {@code time} is null * @since 1.8 */ @SuppressWarnings("deprecation") public static Time valueOf(LocalTime time) { return new Time(time.getHour(), time.getMinute(), time.getSecond()); }
Example 16
Source File: Time.java From jdk8u_jdk with GNU General Public License v2.0 | 2 votes |
/** * Obtains an instance of {@code Time} from a {@link LocalTime} object * with the same hour, minute and second time value as the given * {@code LocalTime}. * * @param time a {@code LocalTime} to convert * @return a {@code Time} object * @exception NullPointerException if {@code time} is null * @since 1.8 */ @SuppressWarnings("deprecation") public static Time valueOf(LocalTime time) { return new Time(time.getHour(), time.getMinute(), time.getSecond()); }
Example 17
Source File: Time.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Obtains an instance of {@code Time} from a {@link LocalTime} object * with the same hour, minute and second time value as the given * {@code LocalTime}. The nanosecond field from {@code LocalTime} is * not part of the newly created {@code Time} object. * * @param time a {@code LocalTime} to convert * @return a {@code Time} object * @exception NullPointerException if {@code time} is null * @since 1.8 */ @SuppressWarnings("deprecation") public static Time valueOf(LocalTime time) { return new Time(time.getHour(), time.getMinute(), time.getSecond()); }
Example 18
Source File: Time.java From jdk1.8-source-analysis with Apache License 2.0 | 2 votes |
/** * Obtains an instance of {@code Time} from a {@link LocalTime} object * with the same hour, minute and second time value as the given * {@code LocalTime}. * * @param time a {@code LocalTime} to convert * @return a {@code Time} object * @exception NullPointerException if {@code time} is null * @since 1.8 */ @SuppressWarnings("deprecation") public static Time valueOf(LocalTime time) { return new Time(time.getHour(), time.getMinute(), time.getSecond()); }
Example 19
Source File: Time.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 2 votes |
/** * Obtains an instance of {@code Time} from a {@link LocalTime} object * with the same hour, minute and second time value as the given * {@code LocalTime}. * * @param time a {@code LocalTime} to convert * @return a {@code Time} object * @exception NullPointerException if {@code time} is null * @since 1.8 */ @SuppressWarnings("deprecation") public static Time valueOf(LocalTime time) { return new Time(time.getHour(), time.getMinute(), time.getSecond()); }
Example 20
Source File: Time.java From JDKSourceCode1.8 with MIT License | 2 votes |
/** * Obtains an instance of {@code Time} from a {@link LocalTime} object * with the same hour, minute and second time value as the given * {@code LocalTime}. * * @param time a {@code LocalTime} to convert * @return a {@code Time} object * @exception NullPointerException if {@code time} is null * @since 1.8 */ @SuppressWarnings("deprecation") public static Time valueOf(LocalTime time) { return new Time(time.getHour(), time.getMinute(), time.getSecond()); }