當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalTime.getMinute方法代碼示例

本文整理匯總了Java中java.time.LocalTime.getMinute方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalTime.getMinute方法的具體用法?Java LocalTime.getMinute怎麽用?Java LocalTime.getMinute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.getMinute方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.time.LocalTime; //導入方法依賴的package包/類
public static void main(String[] args) {
    LocalTime movieStartTime = LocalTime.parse("21:00:00");
    int commuteMin = 35;
    LocalTime shreyaStartTime = movieStartTime.minusMinutes(commuteMin);
    System.out.println("Start by" + shreyaStartTime + " from the office");

    // second example
    int worldRecord = 10;
    LocalTime raceStartTime = LocalTime.of(8, 10, 55);
    System.out.println("raceStartTime: " + raceStartTime);
    LocalTime raceEndTime = LocalTime.of(8, 11, 11);
    System.out.println("raceEndTime: " + raceEndTime);
    System.out.println("raceEndTime plus 10 seconds: " + raceStartTime.plusSeconds(worldRecord));

    if (raceStartTime.plusSeconds(worldRecord).isAfter(raceEndTime)) {
        System.out.println("New world record");
    } else {
        System.out.println("Try harder");
    }

    // whith
    LocalTime startTime = LocalTime.of(5, 7, 9);
    if (startTime.getMinute() < 30) {
        startTime = startTime.withMinute(0);
    }
    System.out.println(startTime);

}
 
開發者ID:huby,項目名稱:java-se8-oca-study-guide,代碼行數:29,代碼來源:Main.java

示例2: updateValue

import java.time.LocalTime; //導入方法依賴的package包/類
private void updateValue() {
    int hour = 0;
    int minute = 0;
    try {
        hour = Math.max(0, Math.min(23, Integer.parseInt(hourField.getText())));
        minute = Math.max(0, Math.min(59, Integer.parseInt(minuteField.getText())));
    } catch (NumberFormatException ex) {
        // do nothing
    }

    /*
     * LocalTime is immutable, hence we have to create new instances over
     * and over again, which causes property change events. So we have to
     * have this check here to ensure that the value has really changed. And
     * we only care about hours and minutes, so we are not using
     * LocalTime.equals().
     */
    LocalTime oldTime = getSkinnable().getValue();
    LocalTime newTime = LocalTime.of(hour, minute);

    if (oldTime != null && newTime != null) {
        if (!(oldTime.getHour() == newTime.getHour() && oldTime.getMinute() == newTime.getMinute())) {
            getSkinnable().setValue(newTime);
        }
    } else if (newTime == null) {
        getSkinnable().setValue(null);

    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:30,代碼來源:TimeFieldSkin.java

示例3: actionPerformed

import java.time.LocalTime; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
	LocalTime localeTime = LocalTime.now();

	int hour = localeTime.getHour();
	int minute = localeTime.getMinute();
	int second = localeTime.getSecond();

	timeText.setText(String.format("%02d : %02d : %02d", hour, minute, second));
}
 
開發者ID:AitorB,項目名稱:POPBL_V,代碼行數:11,代碼來源:Time.java

示例4: test_time_print

import java.time.LocalTime; //導入方法依賴的package包/類
@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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:TCKLocalizedPrinterParser.java

示例5: test_time_parse

import java.time.LocalTime; //導入方法依賴的package包/類
@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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:TCKLocalizedPrinterParser.java

示例6: isEqual

import java.time.LocalTime; //導入方法依賴的package包/類
private static boolean isEqual(LocalTime lt, java.sql.Time t) {
    return lt.getHour() == t.getHours() &&
           lt.getMinute() == t.getMinutes() &&
           lt.getSecond() == t.getSeconds();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:JavatimeTest.java

示例7: valueOf

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * 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());
}
 
開發者ID:madHEYsia,項目名稱:ClassroomFlipkart,代碼行數:15,代碼來源:Time.java

示例8: valueOf

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * 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());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:Time.java


注:本文中的java.time.LocalTime.getMinute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。