Examples of JDateTime


Examples of jodd.datetime.JDateTime

  protected final JDateTime sessionStart;
  protected User user;

  public UserSession(User user) {
    this.user = user;
    sessionStart = new JDateTime();
  }
View Full Code Here

Examples of jodd.datetime.JDateTime

      StreamUtil.close(in);
    }


    String[] queries = StringUtil.splitc(sql, ";");
    JDateTime jdt = new JDateTime();
    jdt.subDay(61)// we have 62 pre-defined questions in total

    DbSession dbSession = AppCore.ref.createDbSession();
    for (int i = 0; i < queries.length; i++) {
      String q = queries[i];
      q = cleanSql(q);
      if (q.isEmpty()) {
        continue;
      }
     
      if (q.contains("$date")) {
        q = StringUtil.replace(q, "$date", jdt.toString("YYYYMMDD"));
        jdt.addDay(1);
      }

      DbQuery query = new DbQuery(dbSession, q);
      query.executeUpdate();
      log.debug("executed query #" + (i + 1));
View Full Code Here

Examples of jodd.datetime.JDateTime

  public static JDateTime toJDateTime(int date) {
    int year = date / 10000;
    date -= year * 10000;
    int month = date / 100;
    date -= month * 100;
    return new JDateTime(year, month, date);
  }
View Full Code Here

Examples of jodd.datetime.JDateTime

  /**
   * Returns current date in int format.
   * @see #toIntDate(jodd.datetime.JDateTime)
   */
  public static int currentIntDate() {
    return toIntDate(new JDateTime());
  }
View Full Code Here

Examples of jodd.datetime.JDateTime

  public static void main(String[] args) {
    new AppWebRunner() {
      @Override
      public void run() {
        QuestionService qs = petite.getBean(QuestionService.class);
        Question q = qs.findQuestionForDate(new JDateTime());
        System.out.println(q.getText());
      }
    }.runWebApp();
  }
View Full Code Here

Examples of jodd.datetime.JDateTime

   public static NanoTime getNanoTime(Timestamp ts) {

     Calendar calendar = getCalendar();
     calendar.setTime(ts);
     JDateTime jDateTime = new JDateTime(calendar.get(Calendar.YEAR),
       calendar.get(Calendar.MONTH) + 1//java calendar index starting at 1.
       calendar.get(Calendar.DAY_OF_MONTH));
     int days = jDateTime.getJulianDayNumber();

     long hour = calendar.get(Calendar.HOUR_OF_DAY);
     long minute = calendar.get(Calendar.MINUTE);
     long second = calendar.get(Calendar.SECOND);
     long nanos = ts.getNanos();
View Full Code Here

Examples of jodd.datetime.JDateTime

   public static Timestamp getTimestamp(NanoTime nt) {
     int julianDay = nt.getJulianDay();
     long nanosOfDay = nt.getTimeOfDayNanos();

     JDateTime jDateTime = new JDateTime((double) julianDay);
     Calendar calendar = getCalendar();
     calendar.set(Calendar.YEAR, jDateTime.getYear());
     calendar.set(Calendar.MONTH, jDateTime.getMonth() - 1); //java calender index starting at 1.
     calendar.set(Calendar.DAY_OF_MONTH, jDateTime.getDay());

     long remainder = nanosOfDay;
     int hour = (int) (remainder / (NANOS_PER_SECOND * SECONDS_PER_MINUTE * MINUTES_PER_HOUR));
     remainder = remainder % (NANOS_PER_SECOND * SECONDS_PER_MINUTE * MINUTES_PER_HOUR);
     int minutes = (int) (remainder / (NANOS_PER_SECOND * SECONDS_PER_MINUTE));
 
View Full Code Here

Examples of jodd.datetime.JDateTime

    /**
     * 计算开始日期与结束日期相差天数
     * @throws java.text.ParseException
     */
    public int daysBetween(Date startDate, Date endDate) {
        JDateTime joddStartDate = new JDateTime(startDate);
        JDateTime joddEndDate = new JDateTime(endDate);
        int result = joddStartDate.daysBetween(joddEndDate);
        logger.info("日期比较:startDate={}, endDate={}, 相差 {} 天。", startDate, endDate, result);
        return result;
    }
View Full Code Here

Examples of jodd.datetime.JDateTime

  }

  // ---------------------------------------------------------------- configure

  public void configure(TimeAfter annotation) {
    time = new JDateTime(annotation.value());
  }
View Full Code Here

Examples of jodd.datetime.JDateTime

  public static boolean validate(Object value, JDateTime then) {
    if (value == null) {
      return true;
    }
    JDateTime now = Convert.toJDateTime(value);
    return now.isAfter(then);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.