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


Java Dates類代碼示例

本文整理匯總了Java中happy.coding.system.Dates的典型用法代碼示例。如果您正苦於以下問題:Java Dates類的具體用法?Java Dates怎麽用?Java Dates使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: defaultInstance

import happy.coding.system.Dates; //導入依賴的package包/類
private void defaultInstance() {
	props.setProperty("mail.debug", "false");

	final String userName = "[email protected]";
	final String password = "[email protected]";
	props.setProperty("mail.smtp.user", userName);
	props.setProperty("mail.smtp.password", password);

	props.setProperty("mail.from", userName);
	props.setProperty("mail.to", "[email protected]");

	props.setProperty("mail.subject", "Program Notifier from Gmail");
	props.setProperty("mail.text", "Program was finished @" + Dates.now());

	Session.getDefaultInstance(props, new Authenticator() {
		@Override
		protected PasswordAuthentication getPasswordAuthentication() {
			return new PasswordAuthentication(userName, password);
		}
	});
}
 
開發者ID:guoguibing,項目名稱:HappyCoding,代碼行數:22,代碼來源:Gmailer.java

示例2: initFolders

import happy.coding.system.Dates; //導入依賴的package包/類
private void initFolders() {
	String resultPath = cf.getString("result.dir");
	File f = new File(resultPath + File.separator + algoName + File.separator + getFactors() + "_"
			+ Dates.now().replace(" ", "_"));
	f.mkdirs();
	resultFolder = f.getAbsolutePath();
	try {
		logPW = FileUtil.createWriter(resultFolder + File.separator + "log.txt");

		String info = algoName + ": \n" + toString();
		logPW.println(info);

		logPW.println("Training set: " + trainDao.getRatingPath());
		logPW.println("Testing set: " + testDao.getRatingPath());
		logPW.println("Text:" + trainDao.getTextPath());

		logPW.println("-----Training----");
		logPW.println("User: " + numUsers);
		logPW.println("Items: " + numItems);
		logPW.println("Ratings: " + numRates);
		logPW.println();

		logPW.flush();

		resultPW = FileUtil.createWriter(resultFolder + File.separator + "result.csv");
		resultPW.println(info);
		String evalInfo = "Iter,Pre1,Pre3,Pre5,Pre10,Pre20,MAP";
		resultPW.println(evalInfo);

		FileIO.makeDirectory(resultFolder + File.separator + "prediction");

		// copy config file
		Files.copy(new File(configPath), new File(resultFolder + File.separator + "config.txt"));

	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:kite1988,項目名稱:famf,代碼行數:39,代碼來源:Recommender.java

示例3: printEvalInfo

import happy.coding.system.Dates; //導入依賴的package包/類
/**
 * print out the evaluation information for a specific algorithm
 */
private static void printEvalInfo(Recommender algo, Map<Measure, Double> ms) {

	String result = Recommender.getEvalInfo(ms);
	String time = Dates.parse(ms.get(Measure.TrainTime).longValue()) + ","
			+ Dates.parse(ms.get(Measure.TestTime).longValue());
	String evalInfo = String.format("%s,%s,%s,%s", algo.algoName, result, algo.toString(), time);

	Logs.info(evalInfo);
}
 
開發者ID:466152112,項目名稱:HappyResearch,代碼行數:13,代碼來源:LibRec.java

示例4: notifyMe

import happy.coding.system.Dates; //導入依賴的package包/類
/**
 * @throws Exception
 * 
 */
private static void notifyMe(String dest) throws Exception {
	if (!cf.isOn("is.email.notify"))
		return;

	EMailer notifier = new EMailer();
	Properties props = notifier.getProps();

	props.setProperty("mail.debug", "false");

	String host = cf.getString("mail.smtp.host");
	String port = cf.getString("mail.smtp.port");
	props.setProperty("mail.smtp.host", host);
	props.setProperty("mail.smtp.port", port);
	props.setProperty("mail.smtp.auth", cf.getString("mail.smtp.auth"));

	props.put("mail.smtp.socketFactory.port", port);
	props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");

	final String user = cf.getString("mail.smtp.user");
	final String pwd = cf.getString("mail.smtp.password");
	props.setProperty("mail.smtp.user", user);
	props.setProperty("mail.smtp.password", pwd);

	props.setProperty("mail.from", user);
	props.setProperty("mail.to", cf.getString("mail.to"));

	props.setProperty("mail.subject", FileIO.getCurrentFolder() + "." + algorithm + " [" + Systems.getIP() + "]");
	props.setProperty("mail.text", "Program was finished @" + Dates.now());

	String msg = "Program [" + algorithm + "] has been finished !";
	notifier.send(msg, dest);
}
 
開發者ID:466152112,項目名稱:HappyResearch,代碼行數:37,代碼來源:LibRec.java

示例5: reportProgress

import happy.coding.system.Dates; //導入依賴的package包/類
protected void reportProgress(int size) {
	int step = params.RUNTIME_PROGRESS_STEP;
	if (size < step)
		step = size / 5;
	++progress;
	if (step > 0 && progress % step == 0) {
		sw.stop();
		long remaining = (long) ((size - progress + 0.0) / step * sw.elapsed(TimeUnit.MILLISECONDS));
		Logs.debug("{} progress: {}/{}, remaining {}", new Object[] { Thread.currentThread().getName(), progress,
				size, Dates.parse(remaining) });
		sw.start();
	}
}
 
開發者ID:466152112,項目名稱:HappyResearch,代碼行數:14,代碼來源:Thread_t.java

示例6: collectResults

import happy.coding.system.Dates; //導入依賴的package包/類
public static void collectResults() throws Exception
{
	String mode = params.BATCH_RUN ? DatasetMode.batch.label : params.DATASET_MODE.label;
	String program = methodId + " [" + mode + "]";

	/* Collect result files to specific directory */
	Path source = FileSystems.getDefault().getPath("results.txt");
	Path target = FileSystems.getDefault().getPath(
			FileIO.makeDirectory(AbstractCF.params.RESULTS_DIRECTORY + Dataset.LABEL) + program + "@"
					+ Dates.now() + ".txt");
	Files.copy(source, target);
	if (params.BATCH_RUN && params.numRunMethod > 1 && numRunMethod < params.numRunMethod) FileIO.empty(source
			.toString());

	/* Send email to notify results */
	if (params.EMAIL_NOTIFICATION)
	{
		String text = FileIO.readAsString(source.toString());
		Gmailer notifier = new Gmailer();

		//notifier.getProps().setProperty("mail.to", "[email protected]");
		//notifier.getProps().setProperty("mail.to", "[email protected]");
		notifier.getProps().setProperty("mail.to", "[email protected]");
		//notifier.getProps().setProperty("mail.bcc", "[email protected]");

		notifier.getProps()
				.setProperty("mail.subject", Dataset.LABEL + ": " + program + " From " + Systems.getIP());
		notifier.send(text, target.toString());
	}
}
 
開發者ID:466152112,項目名稱:HappyResearch,代碼行數:31,代碼來源:AbstractCF.java

示例7: printSpecs

import happy.coding.system.Dates; //導入依賴的package包/類
public void printSpecs() {
	Logs.info("Starts at {}", Dates.now());
	Logs.info(null);

	String suffix = Strings.repeat('-', 22);
	Logs.info(suffix + " Global Setting " + suffix);
	Logs.info("Currently data set   = {} ({})", Dataset.LABEL, Dataset.DIRECTORY);
	Logs.info("Validation approach  = {}", VALIDATE_METHOD.name());
	Logs.info("Prediction method    = {}", PREDICT_METHOD.name());
	Logs.info("Calculate similarity = {}", params.SIMILARITY_METHOD);

	Logs.info(null);
	Logs.info(suffix + " Method Results " + suffix);
}
 
開發者ID:466152112,項目名稱:HappyResearch,代碼行數:15,代碼來源:ConfigParams.java

示例8: notifyMe

import happy.coding.system.Dates; //導入依賴的package包/類
/**
 * copy result file (default: "results.txt") to destination fold (default: "./Results"), and then notify me by email
 * 
 * 
 * @param algo
 *            the algorithm or method executed
 * 
 * @param mailTo
 *            the email address of receiver
 * @param isNotify
 *            whether to notify me by Gmail
 * 
 * @throws Exception
 */
public static void notifyMe(String algo, String mailTo, boolean isNotify) throws Exception {

	String destPath = FileIO.makeDirectory("Results");
	String dest = destPath + algo + "@" + Dates.now() + ".txt";
	FileIO.copyFile("results.txt", dest);

	if (isNotify) {
		Gmailer notifier = new Gmailer();
		notifier.getProps().setProperty("mail.to", mailTo);
		notifier.getProps().setProperty("mail.subject",
				FileIO.getCurrentFolder() + "." + algo + "@" + Systems.getIP());
		notifier.send("Program [" + algo + "] has been finished !", dest);
	}
}
 
開發者ID:guoguibing,項目名稱:HappyCoding,代碼行數:29,代碼來源:FileIO.java

示例9: main

import happy.coding.system.Dates; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
	// Logs.debug(LibRec.readme());

	// get configuration file
	cf = new Configer("librec.conf");

	// debug info
	debugInfo();

	// prepare data
	rateDao = new DataDAO(cf.getPath("dataset.training"));
	rateMatrix = rateDao.readData(cf.getDouble("val.binary.threshold"));

	// config general recommender
	Recommender.cf = cf;
	Recommender.rateMatrix = rateMatrix;
	Recommender.rateDao = rateDao;

	// required: only one parameter varying for multiple run
	Recommender.params = RecUtils.buildParams(cf);

	// run algorithms
	if (Recommender.params.size() > 0) {
		// multiple run
		for (Entry<String, List<Float>> en : Recommender.params.entrySet()) {
			for (int i = 0, im = en.getValue().size(); i < im; i++) {
				LibRec.paramIdx = i;
				runAlgorithm();

				// useful for some methods which do not use the parameters
				// defined in Recommender.params
				if (!isMultRun)
					break;
			}
		}

	} else {
		// single run
		runAlgorithm();
	}

	// collect results
	String destPath = FileIO.makeDirectory("Results");
	String dest = destPath + algorithm + "@" + Dates.now() + ".txt";
	FileIO.copyFile("results.txt", dest);

	notifyMe(dest);
}
 
開發者ID:466152112,項目名稱:HappyResearch,代碼行數:49,代碼來源:LibRec.java

示例10: main

import happy.coding.system.Dates; //導入依賴的package包/類
public static void main(String[] args) throws Exception {

		// Logs.config(FileIO.getResource("log4j.properties"), false);
		conf = new Configer("tp.conf");

		dataset = conf.getString("dataset");
		testView = conf.getString("test.view");

		dirPath = FileIO.makeDirPath(conf.getPath("dataset.dir"), dataset);

		switch (conf.getString("method")) {
		case "ETAF":
			ETAF tm = new ETAF();
			for (Float alpha : conf.getRange("val.ETAF.alpha")) {
				// alpha for trust combination
				tm.alpha = alpha.floatValue();

				for (Float gamma : conf.getRange("val.ETAF.gamma")) {
					// gamma for ability combination
					tm.gamma = gamma.floatValue();

					tm.isIn = conf.isOn("is.ETAF.in");
					if (tm.isIn) {
						for (Float eta : conf.getRange("val.ETAF.eta")) {
							// eta for integrity combination
							tm.eta = eta.floatValue();

							Logs.debug("Settings: alpha = {}, gamma = {}, eta = {}, in = {}",
									new Object[] { alpha.floatValue(), gamma.floatValue(), eta.floatValue(), tm.isIn });
							settings = alpha + sep + gamma + sep + eta + sep + tm.isIn;

							tm.execute();
						}
					} else {
						// not to consider integrity at all
						tm.eta = 1f;

						Logs.debug("Settings: alpha = {}, gamma = {}, in = {}", new Object[] { alpha.floatValue(),
								gamma.floatValue(), tm.isIn });
						settings = alpha + sep + gamma + sep + tm.isIn;

						tm.execute();
					}
				}
			}
			break;
		case "TAF":
			new TAF().execute();
			break;
		case "EPT":
			EPT ept = new EPT();
			List<Float> Nmins = conf.getRange("num.EPT.Nmin");
			for (Float n : Nmins) {
				ept.Nmin = n.intValue();

				Logs.debug("Settings: Nmin = {}", ept.Nmin);
				settings = "" + ept.Nmin;

				ept.execute();
			}
			break;
		default:
			break;
		}

		String destPath = FileIO.makeDirectory(dirPath, "Results");
		String dest = destPath + model + "@" + Dates.now() + ".txt";
		FileIO.copyFile("results.txt", dest);

		if (conf.isOn("is.email.notify")) {
			Gmailer notifier = new Gmailer();

			notifier.getProps().setProperty("mail.to", "[email protected]");
			notifier.getProps().setProperty("mail.subject",
					FileIO.getCurrentFolder() + "-" + model + " is finished @ " + Systems.getIP());
			notifier.send("Program " + model + " has been finished!", dest);
		}
	}
 
開發者ID:466152112,項目名稱:HappyResearch,代碼行數:79,代碼來源:TrustModel.java

示例11: printEvalInfo

import happy.coding.system.Dates; //導入依賴的package包/類
private void printEvalInfo(long trainTime, long testTime) throws IOException {
	String result = getEvalInfo(measures, numIters);

	measures.put(Measure.TrainTime, (double) trainTime);
	measures.put(Measure.TestTime, (double) testTime);

	String evalInfo = result + "\nTime: " + Dates.parse(measures.get(Measure.TrainTime).longValue()) + ", "
			+ Dates.parse(measures.get(Measure.TestTime).longValue());

	resultPW.println(evalInfo);
	resultPW.flush();

}
 
開發者ID:kite1988,項目名稱:famf,代碼行數:14,代碼來源:Recommender.java


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