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


Java Date.equals方法代码示例

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


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

示例1: getDatesBetween

import java.util.Date; //导入方法依赖的package包/类
/**
 * This function will return a list of dates which are between the start and end dates given.
 *
 * @param start : The start date.
 * @param end   : The end date.
 * @return The list of dates.
 */
private List<Date> getDatesBetween(Date start, Date end) {
    Date cursor = start;

    Calendar cal = Calendar.getInstance();
    List<Date> results = new ArrayList<>();
    while (!cursor.equals(end)) {
        results.add(cursor);

        cal.setTime(cursor);
        cal.add(Calendar.DATE, 1);
        cursor = cal.getTime();
    }
    if (!results.contains(end)) {
        results.add(end);
    }
    return results;
}
 
开发者ID:Snooze986,项目名称:SonoESEO-Android,代码行数:25,代码来源:CalendarFragment.java

示例2: hasTaskChanged

import java.util.Date; //导入方法依赖的package包/类
@Override
public boolean hasTaskChanged(@NonNull TaskRepository taskRepository, @NonNull ITask task,
		@NonNull TaskData taskData) {

	Date changedAtTaskData = taskData.getAttributeMapper()
			.getDateValue(taskData.getRoot().getAttribute(TaskAttribute.DATE_MODIFICATION));
	Date changedAtTask = task.getModificationDate();

	if (changedAtTask == null || changedAtTaskData == null)
		return true;

	if (!changedAtTask.equals(changedAtTaskData))
		return true;

	return false;
}
 
开发者ID:theits,项目名称:CharmMylynConnector,代码行数:17,代码来源:CharmRepositoryConnector.java

示例3: Test4165343

import java.util.Date; //导入方法依赖的package包/类
/**
 * Adding 12 months behaves differently from adding 1 year
 */
public void Test4165343() {
    GregorianCalendar calendar = new GregorianCalendar(1996, FEBRUARY, 29);
    Date start = calendar.getTime();
    logln("init date: " + start);
    calendar.add(MONTH, 12);
    Date date1 = calendar.getTime();
    logln("after adding 12 months: " + date1);
    calendar.setTime(start);
    calendar.add(YEAR, 1);
    Date date2 = calendar.getTime();
    logln("after adding one year : " + date2);
    if (date1.equals(date2)) {
        logln("Test passed");
    } else {
        errln("Test failed");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:CalendarRegression.java

示例4: getAirportWeather

import java.util.Date; //导入方法依赖的package包/类
public static Weather getAirportWeather(String date, String airportTo, String username, String password) {
	//enable basic login
	HttpHelper.setAuth(username,password);
	HttpHelper.enableAuth(true);
	JsonNode response = HttpHelper.connect("https://twcservice.mybluemix.net/api/weather/v3/location/point?iataCode="+ airportTo +"&language=en-US", "GET", null);
	if (response == null) {
		return null;
	}
	//query the data and get its lat and lon
	String city = response.path("location").path("city").asText();
	double lat = response.path("location").path("latitude").asDouble();
	String latitude = Double.toString(lat);
	double lon = response.path("location").path("longitude").asDouble();
	String longitude = Double.toString(lon);
	JsonNode response2 = HttpHelper.connect("https://twcservice.mybluemix.net/api/weather/v1/geocode/" + latitude + "/" + longitude + "/forecast/daily/10day.json", "GET", null);
	HttpHelper.enableAuth(false);
	JsonNode d10 = response2.get("forecasts");
	try{
		//query data and reformat it to match the Weather class
		DateFormat dates = new SimpleDateFormat("yyyy-MM-dd");
		Date future = dates.parse(date);
		for (JsonNode day : d10) {
			String[] days = day.path("fcst_valid_local").asText().split("T");
			Date dayDate = dates.parse(days[0]);
       		if(future.equals(dayDate)){
       			String weath = day.path("day").path("phrase_22char").asText();
       			int temperture = day.path("day").path("temp").asInt();
       			String narrative = day.path("day").path("narrative").asText();
       			Weather weather = new Weather(date, city, weath, temperture, narrative);
				return weather;
       		}
   		}		
	} catch (Exception e) {
		e.printStackTrace();
	}
	//If we can't find the matching day, return null
	return null;
}
 
开发者ID:IBM,项目名称:Hybrid-Cloud-Applications-and-Services,代码行数:39,代码来源:DatabaseAccess.java

示例5: isSatisfiedBy

import java.util.Date; //导入方法依赖的package包/类
/**
 * Indicates whether the given date satisfies the cron expression. Note that
 * milliseconds are ignored, so two Dates falling on different milliseconds
 * of the same second will always have the same result here.
 * 
 * @param date the date to evaluate
 * @return a boolean indicating whether the given date satisfies the cron
 *         expression
 */
public boolean isSatisfiedBy(Date date) {
    Calendar testDateCal = Calendar.getInstance(getTimeZone());
    testDateCal.setTime(date);
    testDateCal.set(Calendar.MILLISECOND, 0);
    Date originalDate = testDateCal.getTime();
    
    testDateCal.add(Calendar.SECOND, -1);
    
    Date timeAfter = getTimeAfter(testDateCal.getTime());

    return ((timeAfter != null) && (timeAfter.equals(originalDate)));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:CronExpression.java

示例6: compute

import java.util.Date; //导入方法依赖的package包/类
@Override
protected Boolean compute(Date left, Date right) {
	if (left == null && right == null) {
		return true;
	}
	if (left == null || right == null) {
		return false;
	}
	return left.equals(right);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:11,代码来源:Equals.java

示例7: applyMisfire

import java.util.Date; //导入方法依赖的package包/类
protected boolean applyMisfire(TriggerWrapper tw) {

        long misfireTime = System.currentTimeMillis();
        if (getMisfireThreshold() > 0) {
            misfireTime -= getMisfireThreshold();
        }

        Date tnft = tw.trigger.getNextFireTime();
        if (tnft == null || tnft.getTime() > misfireTime 
                || tw.trigger.getMisfireInstruction() == Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY) { 
            return false; 
        }

        Calendar cal = null;
        if (tw.trigger.getCalendarName() != null) {
            cal = retrieveCalendar(tw.trigger.getCalendarName());
        }

        signaler.notifyTriggerListenersMisfired((OperableTrigger)tw.trigger.clone());

        tw.trigger.updateAfterMisfire(cal);

        if (tw.trigger.getNextFireTime() == null) {
            tw.state = TriggerWrapper.STATE_COMPLETE;
            signaler.notifySchedulerListenersFinalized(tw.trigger);
            synchronized (lock) {
                timeTriggers.remove(tw);
            }
        } else if (tnft.equals(tw.trigger.getNextFireTime())) {
            return false;
        }

        return true;
    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:RAMJobStore.java

示例8: checkParseRfc822Date

import java.util.Date; //导入方法依赖的package包/类
private static boolean checkParseRfc822Date() throws ParseException {
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat(
            "EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
    sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
    String formatted = sdf.format(date);
    Date expected = sdf.parse(formatted);
    Date actual2 = new Date(DateUtils.rfc822DateFormat.parseMillis(formatted));
    return expected.equals(actual2);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:11,代码来源:JodaTime.java

示例9: checkGeneralized

import java.util.Date; //导入方法依赖的package包/类
private static  void checkGeneralized(Date d0, byte[] b, String text) throws Exception {
  Date d1 = decodeGeneralized(b);
  if( !d0.equals(d1) ) {
    throw new Exception("GeneralizedTime " + text + " failed: " + d1.toGMTString());
  } else {
    System.out.println("GeneralizedTime " + text + " ok");
  }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:TimeParsing.java

示例10: compareDateNullSafety

import java.util.Date; //导入方法依赖的package包/类
@SuppressWarnings("SimplifiableIfStatement")
public static boolean compareDateNullSafety(@Nullable Date first, @Nullable Date second) {
    if (first == null)
        return second == null;
    else if (second == null)
        return false;
    else
        return first.equals(second);
}
 
开发者ID:shevart,项目名称:Android-SQLite-Master-Project,代码行数:10,代码来源:ComparatorUtils.java

示例11: equals

import java.util.Date; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof DBBlocksJournalProcess)) return false;

    DBBlocksJournalProcess other = (DBBlocksJournalProcess) o;

    Date xactStart = process.getQuery().getXactStart();
    Date otherXactStart = other.getProcess().getQuery().getXactStart();

    boolean isSameXactStart = xactStart == null ? otherXactStart == null : xactStart.equals(otherXactStart);
    boolean isSamePid = process.getPid() == other.getProcess().getPid();

    return isSameXactStart && isSamePid && childrenEquals(process.getChildren(), other.getProcess().getChildren());
}
 
开发者ID:technology16,项目名称:pgsqlblocks,代码行数:16,代码来源:DBBlocksJournalProcess.java

示例12: checkParseIso8601Date

import java.util.Date; //导入方法依赖的package包/类
private static boolean checkParseIso8601Date() throws ParseException {
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat(
            "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
    String formatted = sdf.format(date);
    String alternative = DateUtils.iso8601DateFormat.print(date.getTime());
    if (formatted.equals(alternative)) {
        Date expectedDate = sdf.parse(formatted);
        Date actualDate = DateUtils.doParseISO8601Date(formatted);
        return expectedDate.equals(actualDate);
    }
    return false;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:JodaTime.java

示例13: parseRangeAndUpdate

import java.util.Date; //导入方法依赖的package包/类
protected void parseRangeAndUpdate(Date startDate, Date endDate, String directory,
    PostgreStorage storage, String market)
    throws IOException, ParseException {
  while (startDate.before(endDate) || startDate.equals(endDate)) {
    parseAndUpdate(startDate, directory, storage, market);
    startDate = DateUtils.addDays(startDate, 1);
  }
}
 
开发者ID:longkerdandy,项目名称:qfii-tracker,代码行数:9,代码来源:ConnectParser.java

示例14: read

import java.util.Date; //导入方法依赖的package包/类
public void read() throws Exception {
    FTPClient ftpClient = new FTPClient();
    ftpClient.setBufferSize(1024 * 1024);
    ftpClient.setDefaultTimeout(1000);
    ftpClient.setControlEncoding("UTF-8");
    ftpClient.setDataTimeout(10000);
    ZipFile zipFile = new ZipFile();
    Parser parser = new Parser();
    URL feedUrl = new URL("https://download.kortforsyningen.dk/sites/default/files/feeds/MATRIKELKORT_GML.xml");
    SyndFeedInput input = new SyndFeedInput();
    System.out.println("Henter Atom feed....\n");

    SyndFeed feed = input.build(new XmlReader(feedUrl));
    System.out.println("Feed Titel: " + feed.getTitle());
    Date lastPublishedDate;
    Date currentDate;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String fileName;
    Integer elavsKode;

    Track track = new Track();
    String lastStr = track.getLastFromDb();
    lastPublishedDate = sdf.parse(lastStr);

    System.out.println("\nSidste entry: " + lastStr + "\n");

    this.login(ftpClient);

    for (SyndEntry entry : (List<SyndEntry>) feed.getEntries()) {

        System.out.println("\n--------------\n");

        currentDate = entry.getPublishedDate();

        if (currentDate.before(lastPublishedDate) || currentDate.equals(lastPublishedDate)) {
            break;
        }

        System.out.println("Published Date: " + entry.getPublishedDate() + "\n");

        // Get the Links
        for (SyndLinkImpl link : (List<SyndLinkImpl>) entry.getLinks()) {
            System.out.println("Link: " + link.getHref());
            fileName = link.getHref().split("/")[7];
            elavsKode = Integer.valueOf(fileName.split("_")[0]);
            track.storeInDb(currentDate.toString(), elavsKode);

            // Get the file
            this.c(ftpClient, fileName, zipFile);

            // Get xml stream from zip-file
            ZipInputStream zin = zipFile.getGml(fileName);

            // Parse the xml and insert in database
            parser.build(zin, elavsKode);

            // Delete the file
            File file = new File(fileName);
            file.delete();
        }


    }
    // logout the user, returned true if logout successfully
    ftpClient.disconnect();
    System.out.println("Alt hentet...");
    System.out.println("FTP forbindelse afbrydes.");


}
 
开发者ID:mapcentia,项目名称:AtomMatrikel,代码行数:71,代码来源:Downloader.java

示例15: removeDuplicates

import java.util.Date; //导入方法依赖的package包/类
/**
 * Searches the database for duplicate entries and removes them accordingly.
 *
 * @return True if no duplicate entries were found or all duplicate entries were successfully removed from the database.
 *          False if a duplicate entry could not be removed.
 */
public boolean removeDuplicates() {
    // DELETE FROM MyTable WHERE RowId NOT IN (SELECT MIN(RowId) FROM MyTable GROUP BY Col1, Col2, Col3);
    // but we need a workaround for the or mapper
    try {
        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", true)
                .prepare();
        CloseableIterator<VaultEntry> iterator = vaultDao.iterator(query);

        Date startGenerationTimestamp = null;
        List<VaultEntry> tmpList = new ArrayList<>();
        List<Long> duplicateId = new ArrayList<>();
        while (iterator.hasNext()) {
            VaultEntry entry = iterator.next();
            if (startGenerationTimestamp == null) {
                // start up
                startGenerationTimestamp = entry.getTimestamp();
                tmpList.add(entry);
            } else if (!startGenerationTimestamp
                    .equals(entry.getTimestamp())) {
                // not same timestamp --> new line generation
                startGenerationTimestamp = entry.getTimestamp();
                tmpList.clear();
                tmpList.add(entry);
            } else {
                // same timestamp --> check if it is a duplicate
                for (VaultEntry item : tmpList) {
                    if (item.equals(entry)) {
                        // duplicate --> delete and move on
                        duplicateId.add(entry.getId());
                        break;
                    }
                }
            }
        }

        // delete duplicates
        int lines = vaultDao.deleteIds(duplicateId);
        LOG.log(Level.INFO, "Removed {0} duplicates", lines);
    } catch (SQLException exception) {
        LOG.log(Level.SEVERE, "Error while db query", exception);
        return false;
    }

    return true;
}
 
开发者ID:lucasbuschlinger,项目名称:BachelorPraktikum,代码行数:53,代码来源:VaultDao.java


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