当前位置: 首页>>代码示例>>Java>>正文


Java LocalDateTime.compareTo方法代码示例

本文整理汇总了Java中java.time.LocalDateTime.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDateTime.compareTo方法的具体用法?Java LocalDateTime.compareTo怎么用?Java LocalDateTime.compareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalDateTime的用法示例。


在下文中一共展示了LocalDateTime.compareTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compareTo

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Override
public final int compareTo(Entry<?> other) {
    if (isFullDay() && other.isFullDay()) {
        return getStartDate().compareTo(other.getStartDate());
    }

    if (isFullDay()) {
        return -1;
    }

    if (other.isFullDay()) {
        return +1;
    }

    LocalDateTime a = LocalDateTime.of(getStartDate(), getStartTime());
    LocalDateTime b = LocalDateTime.of(other.getStartDate(), other.getStartTime());
    int result = a.compareTo(b);
    if (result == 0) {
        String titleA = getTitle() != null ? getTitle() : ""; //$NON-NLS-1$
        String titleB = other.getTitle() != null ? other.getTitle() : ""; //$NON-NLS-1$
        result = titleA.compareTo(titleB);
    }

    return result;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:26,代码来源:Entry.java

示例2: splitDatesIntoMonths

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static List<Date[]> splitDatesIntoMonths(Date from, Date to) throws IllegalArgumentException {

    List<Date[]> dates = new ArrayList<>();

    LocalDateTime dFrom = asLocalDateTime(from);
    LocalDateTime dTo = asLocalDateTime(to);

    if (dFrom.compareTo(dTo) >= 0) {
      throw new IllegalArgumentException("Provide a to-date greater than the from-date");
    }

    while (dFrom.compareTo(dTo) < 0) {
      // check if current time frame is last
      boolean isLastTimeFrame = dFrom.getMonthValue() == dTo.getMonthValue() && dFrom.getYear() == dTo.getYear();

      // define day of month based on timeframe. if last - take boundaries from end date, else end of month and date
      int dayOfMonth = isLastTimeFrame ? dTo.getDayOfMonth() : dFrom.with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth();
      LocalTime time = isLastTimeFrame ? dTo.toLocalTime() : LocalTime.MAX;


      // build timeframe
      Date[] dar = new Date[2];
      dar[0] = asDate(dFrom);
      dar[1] = asDate(dFrom.withDayOfMonth(dayOfMonth).toLocalDate().atTime(time));

      // add current timeframe
      dates.add(dar);

      // jump to beginning of next month
      dFrom = dFrom.plusMonths(1).withDayOfMonth(1).toLocalDate().atStartOfDay();
    }

    return dates;

  }
 
开发者ID:YagelNasManit,项目名称:environment.monitor,代码行数:36,代码来源:DataUtils.java

示例3: determineDateRanges

import java.time.LocalDateTime; //导入方法依赖的package包/类
public void determineDateRanges() {
    	for(MatchableTableRow row : records.get()) {
    		
    		for(MatchableTableColumn col : schema.get()) {
    			
    			if(col.getType()==DataType.date) {
    				
    				LocalDateTime[] range = MapUtils.get(dateRanges, col.getColumnIndex(), new LocalDateTime[2]);
    				
    				Map<Integer, Integer> indexTranslation = getPropertyIndices().get(row.getTableId());
    				if(indexTranslation==null) {
    					System.err.println("Missing property index translation for table " + row.getTableId());
    				}
    				
//    				'secondColumnIndex' ('globalId' of dbpedia property) is used to get 'columnIndex' of dbpedia property in a respective table
    				Integer translatedIndex = indexTranslation.get(col.getColumnIndex());
    				if(translatedIndex!=null) {

	    				Object obj = row.get(translatedIndex);
	    				
	    				if(obj!=null && obj instanceof LocalDateTime) {
	    				
	    					LocalDateTime value = (LocalDateTime)row.get(translatedIndex);
	    					
	    					if(range[0]==null || value.compareTo(range[0]) < 0) {
	    						range[0] = value;
	    					}
	    					
	    					if(range[1]==null || value.compareTo(range[1]) > 0) {
	    						range[1] = value;
	    					}
	    					
	    				} else {
	    					if(obj!=null && !(obj instanceof LocalDateTime)) {
	    						System.err.println(String.format("{%s} row %d property %s has value of invalid type: '%s' (%s)", this.classIndices.get(row.getTableId()), row.getRowNumber(), col.getIdentifier(), obj, obj.getClass()));
	    					}
	    				}
    				}
    				
    			}
    			
    		}
    		
    	}
    }
 
开发者ID:olehmberg,项目名称:T2KMatch,代码行数:46,代码来源:KnowledgeBase.java

示例4: RangeOfLocalDateTimes

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * Constructor
 * @param start     the start for range, inclusive
 * @param end       the end for range, exclusive
 * @param step      the step increment
 * @param excludes  optional predicate to exclude elements in this range
 */
RangeOfLocalDateTimes(LocalDateTime start, LocalDateTime end, Duration step, Predicate<LocalDateTime> excludes) {
    super(start, end);
    this.step = step;
    this.ascend = start.compareTo(end) <= 0;
    this.excludes = excludes;
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:14,代码来源:RangeOfLocalDateTimes.java

示例5: inBounds

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * Checks that the value specified is in the bounds of this range
 * @param value     the value to check if in bounds
 * @return          true if in bounds
 */
private boolean inBounds(LocalDateTime value) {
    return ascend ? value.compareTo(start()) >=0 && value.isBefore(end()) : value.compareTo(start()) <=0 && value.isAfter(end());
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:9,代码来源:RangeOfLocalDateTimes.java


注:本文中的java.time.LocalDateTime.compareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。