joda api将时间范围切成间隔

时间:2016-07-16 05:06:59

标签: java jodatime

我必须将时间范围分成15分钟的间隔。 输入时间可以是12小时或24小时格式。 joda是否提供了将时间范围切割成所需间隔的方法?

ex: 

    input:
    startTime: 08:00 AM or 08:00 endTime: 2:00 PM or 14:00

    output:
    08:00, 08:15, 08:30, 08:45...............

1 个答案:

答案 0 :(得分:0)

对于时间增量,只需使用time.plusMinutes()或time.plusHours()。  要检查greter是否比han使用time.isBefore()或time.isAfter()。

PROGRAM AT3 (input, output);
uses crt, math;
CONST
    band6 = 90;
    band5 = 80;
    band4 = 70;
    band3 = 60;
    band2 = 50;
VAR
    Studname : array of string;
    studmark : array of integer;
    flag : boolean;
    studinfo : text;
    input : string;
    count : integer;
    num : integer;
        input2: integer;
    highmark, lowmark : integer;
    median, average : integer;

BEGIN
    lowmark := 100;
    highmark := 0;
    median := 0;
    ASSIGN (Studinfo, 'ExamResults.txt');
    flag := false;
    WRITELN('welcome to the Band generator.');
        WRITELN('To enter student results, please enter the number of students. To see class statistics, please type zzz. To clear the screen type clear screen. And to exit the program, type exit');
    While flag = false DO
        ReadLN (input);
        IF input = 'zzz' THEN
            WHILE not EOF(Studinfo) DO
            BEGIN
                WRITELN(studinfo);
            END;
        IF input = 'exit' THEN
            Flag := true;
                IF input = 'clear screen' THEN
                        CLRSCR
                ELSE
                    if input2 <> 0 THEN
                        num := input2
                ELSE
                WRITELN('Please enter a valid number.');
        FOR count := 0 to num-1 DO
            BEGIN
            WRITELN('Please enter name of student', count);
            read(studname[count]);
            WRITE(studinfo, studname[count]);
            WRITELN('Please enter mark of student', count, 'out of 100 (nearest whole number)');
            read(studmark[count]);              write(studinfo, studmark[count]);
            IF studmark[count] >=band6 THEN
                WRITELN(studinfo, 'band6');
            IF studmark[count] >=band5 THEN
                WRITELN(studinfo, 'band5');
            IF studmark[count] >=band4 THEN
                WRITELN(studinfo, 'band4');
            IF studmark[count] >=band3 THEN
                WRITELN(studinfo, 'band3');
            IF studmark[count] >=band2 THEN
                WRITELN(studinfo, 'band2');
            IF studmark[count] <band2 THEN
                WRITELN(studinfo, 'band1');
            IF studmark[count] >= highmark THEN
                highmark := studmark[count];
            IF studmark[count] <= lowmark THEN
                lowmark := studmark[count];
            END;
        median := highmark MOD 2;

    CLOSE(studinfo);
END.