コード例 #1
0
 public void testParse() {
   Calendar c1 = Calendar.getInstance();
   c1.set(2012, 5 - 1, 1, 0, 0, 0);
   c1.set(Calendar.MILLISECOND, 0);
   Date date = c1.getTime();
   assertEquals(date, DateUtil.parse("2012-05-01"));
 }
コード例 #2
0
  public static TimeSchedule2 getTimeSchedule2(String startTime, String endTime) {
    TimeSchedule2 timeSchedule = new TimeSchedule2();

    SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    if (null == startTime) {

      startTime = DateUtil.format(DateUtil.parse(endTime), "yyyy-MM-dd");
      startTime = startTime + " 00:00:00";

    } else {
      startTime = DateUtil.format(DateUtil.parse(startTime), "yyyy-MM-dd");
      startTime = startTime + " 00:00:00";
    }

    try {

      java.util.Date begin = dfs.parse(startTime);
      java.util.Date end = dfs.parse(endTime);
      long between = (end.getTime() - begin.getTime()) / 1000; // 除以1000是为了转换成秒

      long days = (between / 60) / (24 * 60);
      long hours = (between / 60) % (24 * 60) / 60;
      long minutes = (between / 60) % 60;
      long seconds = between - days * (24 * 60 * 60) - hours * (60 * 60) - minutes * 60;

      timeSchedule.setDates(days);
      timeSchedule.setHour(hours);
      timeSchedule.setMinute(minutes);
      timeSchedule.setSecond(seconds);

    } catch (ParseException e) {

      e.printStackTrace();
    }

    return timeSchedule;
  }
コード例 #3
0
  public void init() {
    init(System.getProperty("user.dir") + "/conf/log4j.conf");
    init(System.getProperty("user.dir") + "/conf/system.conf");
    PropertyConfigurator.configure(p);

    seletor_model = getProperty("select.model", "timer");

    timer_start_time = DateUtil.parse(getProperty("timer.start_time", DateUtil.getCurrentTime()));
    timer_interval = Long.valueOf(CalculateUtil.parseExp(getProperty("timer.interval", "0")));

    zk_address = getProperty("zookeeper.address", "hdfs://localhost:9000");
    zk_retry = Integer.valueOf(getProperty("zookeeper.retry", "3"));

    hdfs_address = getProperty("hdfs.address", "hdfs://localhost:9000");
    hdfs_itemcf_input = getProperty("hdfs.itemcf.input", "hdfs://localhost:9000/itemcf/input");
    hdfs_itemcf_client_input = hdfs_itemcf_input + "/data";
    hdfs_itemcf_output = getProperty("hdfs.itemcf.output", "hdfs://localhost:9000/itemcf/output");
    hdfs_itemcf_boolean_input = Constants.hdfs_address + "/boolean_input";
    hdfs_itemcf_boolean_output = Constants.hdfs_address + "/boolean_output";
    hdfs_itemcf_tempdir = getProperty("hdfs.itemcf.tmp", "hdfs://localhost:9000/tmp");

    kmeans_k = Integer.valueOf(getProperty("kmeans.k", "3"));
    kmeans_convergence_delta = Double.valueOf(getProperty("kmeans.con_delta", "0.5"));
    kmeans_max_iterations = Integer.valueOf(getProperty("kmeans.max_itera", "3"));

    hdfs_kmeans_input = getProperty("hdfs.kmeans.input", "hdfs://localhost:9000/kmeans/input");
    hdfs_kmeans_output = getProperty("hdfs.kmeans.output", "hdfs://localhost:9000/kmeans/output");
    hdfs_kmeans_random_output_path = hdfs_kmeans_output + "/cluster";
    hdfs_kmeans_seq_output_path = hdfs_kmeans_output + "/randomseed";
    hdfs_kmeans_point_output_path = hdfs_kmeans_output + "/clusteredPoints";
    hdfs_kmeans_input_file = hdfs_kmeans_input + "/data";

    hbase_master = getProperty("hbase.master", "localhost");
    hbase_zk_quorum = getProperty("hbase.zk_quorum", "localhost");
    hbase_zk_client_port = Integer.valueOf(getProperty("hbase.zk_client_port", "2181"));

    mahout_similarityclassname =
        similarity_class_path
            + getSimilarityClassName(
                getProperty("mahout.itemcf.similarity", "EuclideanDistanceSimilarity"));
    mahout_distanceclass = getDistanceClass(getProperty("mahout.kmeans.distance", "manhattan"));

    logger.info("configuration files init finish.");
  }