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


Java ReadablePeriod类代码示例

本文整理汇总了Java中org.joda.time.ReadablePeriod的典型用法代码示例。如果您正苦于以下问题:Java ReadablePeriod类的具体用法?Java ReadablePeriod怎么用?Java ReadablePeriod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Schedule

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
public Schedule(int projectId, String projectName, String flowName,
    String status, long firstSchedTime, DateTimeZone timezone,
    ReadablePeriod period, long lastModifyTime, long nextExecTime,
    long submitTime, String submitUser) {
  this.projectId = projectId;
  this.projectName = projectName;
  this.flowName = flowName;
  this.firstSchedTime = firstSchedTime;
  this.timezone = timezone;
  this.lastModifyTime = lastModifyTime;
  this.period = period;
  this.nextExecTime = nextExecTime;
  this.submitUser = submitUser;
  this.status = status;
  this.submitTime = submitTime;
  this.executionOptions = null;
  this.slaOptions = null;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:19,代码来源:Schedule.java

示例2: getNextRuntime

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
private DateTime getNextRuntime(long scheduleTime, DateTimeZone timezone,
    ReadablePeriod period) {
  DateTime now = new DateTime();
  DateTime date = new DateTime(scheduleTime).withZone(timezone);
  int count = 0;
  while (!now.isBefore(date)) {
    if (count > 100000) {
      throw new IllegalStateException(
          "100000 increments of period did not get to present time.");
    }

    if (period == null) {
      break;
    } else {
      date = date.plus(period);
    }

    count += 1;
  }

  return date;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:23,代码来源:Schedule.java

示例3: fromObject

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static SlaSetting fromObject(Object obj) {
  Map<String, Object> slaObj = (HashMap<String, Object>) obj;
  String subId = (String) slaObj.get("id");
  ReadablePeriod dur =
      Schedule.parsePeriodString((String) slaObj.get("duration"));
  // List<String> rulesObj = (ArrayList<String>) slaObj.get("rules");
  // List<SlaRule> slaRules = new ArrayList<SLA.SlaRule>();
  // for(String rule : rulesObj) {
  // slaRules.add(SlaRule.valueOf(rule));
  // }
  SlaRule slaRule = SlaRule.valueOf((String) slaObj.get("rule"));
  List<String> actsObj = (ArrayList<String>) slaObj.get("actions");
  List<SlaAction> slaActs = new ArrayList<SlaAction>();
  for (String act : actsObj) {
    slaActs.add(SlaAction.valueOf(act));
  }

  SlaSetting ret = new SlaSetting();
  ret.setId(subId);
  ret.setDuration(dur);
  ret.setRule(slaRule);
  ret.setActions(slaActs);
  return ret;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:26,代码来源:SLA.java

示例4: Schedule

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
public Schedule(int scheduleId, int projectId, String projectName,
    String flowName, String status, long firstSchedTime,
    DateTimeZone timezone, ReadablePeriod period, long lastModifyTime,
    long nextExecTime, long submitTime, String submitUser,
    ExecutionOptions executionOptions, List<SlaOption> slaOptions) {
  this.scheduleId = scheduleId;
  this.projectId = projectId;
  this.projectName = projectName;
  this.flowName = flowName;
  this.firstSchedTime = firstSchedTime;
  this.timezone = timezone;
  this.lastModifyTime = lastModifyTime;
  this.period = period;
  this.nextExecTime = nextExecTime;
  this.submitUser = submitUser;
  this.status = status;
  this.submitTime = submitTime;
  this.executionOptions = executionOptions;
  this.slaOptions = slaOptions;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:21,代码来源:Schedule.java

示例5: scheduleFlow

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
public Schedule scheduleFlow(final int scheduleId, final int projectId,
    final String projectName, final String flowName, final String status,
    final long firstSchedTime, final DateTimeZone timezone,
    final ReadablePeriod period, final long lastModifyTime,
    final long nextExecTime, final long submitTime, final String submitUser,
    ExecutionOptions execOptions, List<SlaOption> slaOptions) {
  Schedule sched =
      new Schedule(scheduleId, projectId, projectName, flowName, status,
          firstSchedTime, timezone, period, lastModifyTime, nextExecTime,
          submitTime, submitUser, execOptions, slaOptions);
  logger
      .info("Scheduling flow '" + sched.getScheduleName() + "' for "
          + _dateFormat.print(firstSchedTime) + " with a period of " + period == null ? "(non-recurring)"
          : period);

  insertSchedule(sched);
  return sched;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:19,代码来源:ScheduleManager.java

示例6: createFromJson

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
public static BasicTimeChecker createFromJson(HashMap<String, Object> obj)
    throws Exception {
  Map<String, Object> jsonObj = (HashMap<String, Object>) obj;
  if (!jsonObj.get("type").equals(type)) {
    throw new Exception("Cannot create checker of " + type + " from "
        + jsonObj.get("type"));
  }
  Long firstCheckTime = Long.valueOf((String) jsonObj.get("firstCheckTime"));
  String timezoneId = (String) jsonObj.get("timezone");
  long nextCheckTime = Long.valueOf((String) jsonObj.get("nextCheckTime"));
  DateTimeZone timezone = DateTimeZone.forID(timezoneId);
  boolean isRecurring = Boolean.valueOf((String) jsonObj.get("isRecurring"));
  boolean skipPastChecks =
      Boolean.valueOf((String) jsonObj.get("skipPastChecks"));
  ReadablePeriod period =
      Utils.parsePeriodString((String) jsonObj.get("period"));
  String id = (String) jsonObj.get("id");

  BasicTimeChecker checker =
      new BasicTimeChecker(id, firstCheckTime, timezone, nextCheckTime,
          isRecurring, skipPastChecks, period);
  if (skipPastChecks) {
    checker.updateNextCheckTime();
  }
  return checker;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:27,代码来源:BasicTimeChecker.java

示例7: apply

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  Object top = stack.pop();
  
  if (!(top instanceof Long)) {
    throw new WarpScriptException(getName() + " expects a number of time units (LONG) on top of the stack.");
  }
  
  long duration = ((Number) top).longValue();
  
  StringBuffer buf = new StringBuffer();
  ReadablePeriod period = new MutablePeriod(duration / Constants.TIME_UNITS_PER_MS);
  ISOPeriodFormat.standard().getPrinter().printTo(buf, period, Locale.US);

  stack.push(buf.toString());
  
  return stack;
}
 
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:19,代码来源:ISODURATION.java

示例8: buildLogicalTable

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
/**
 * Build a logical table, supplying it with a name, grain, table group, and metrics.
 * <p>
 * Note: This builds a logical table with all valid metrics for the grain of the table.
 *
 * @param name  The name for this logical table
 * @param granularity  The granularity for this logical table
 * @param category  The category for this logical table
 * @param longName  The long name for this logical table
 * @param retention  The retention for this logical table
 * @param description  The description for this logical table
 * @param group  The group of physical tables for this logical table
 * @param metrics  The dictionary of all metrics
 *
 * @return The logical table built
 *
 * @deprecated The LogicalTable constructor is being mirrored here, can be referenced directly
 */
@Deprecated
public LogicalTable buildLogicalTable(
        String name,
        Granularity granularity,
        String category,
        String longName,
        ReadablePeriod retention,
        String description,
        TableGroup group,
        MetricDictionary metrics
) {
    return new LogicalTable(
            name,
            category,
            longName,
            granularity,
            retention,
            description,
            group,
            metrics
    );
}
 
开发者ID:yahoo,项目名称:fili,代码行数:41,代码来源:BaseTableLoader.java

示例9: LogicalTable

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param name  The logical table name
 * @param category  The category of the logical table
 * @param longName  The long name of the logical table
 * @param granularity  The logical table time grain
 * @param retention  The period the data in the logical table is retained for
 * @param description  The description for this logical table
 * @param tableGroup  The tablegroup for the logical table
 * @param metricDictionary The metric dictionary to bind tableGroup's metrics
 */
public LogicalTable(
        @NotNull String name,
        String category,
        String longName,
        @NotNull Granularity granularity,
        ReadablePeriod retention,
        String description,
        TableGroup tableGroup,
        MetricDictionary metricDictionary
) {
    this.name = name;
    this.tableGroup = tableGroup;
    this.category = category;
    this.longName = longName;
    this.retention = retention;
    this.description = description;
    this.comparableParam = name + granularity.toString();

    schema = new LogicalTableSchema(tableGroup, granularity, metricDictionary);

}
 
开发者ID:yahoo,项目名称:fili,代码行数:34,代码来源:LogicalTable.java

示例10: between

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
/**
 * Calculates the number of whole units between the two specified partial datetimes.
 * <p>
 * The two partials must contain the same fields, for example you can specify
 * two <code>LocalDate</code> objects.
 *
 * @param start  the start partial date, validated to not be null
 * @param end  the end partial date, validated to not be null
 * @param zeroInstance  the zero instance constant, must not be null
 * @return the period
 * @throws IllegalArgumentException if the partials are null or invalid
 */
protected static int between(ReadablePartial start, ReadablePartial end, ReadablePeriod zeroInstance) {
    if (start == null || end == null) {
        throw new IllegalArgumentException("ReadablePartial objects must not be null");
    }
    if (start.size() != end.size()) {
        throw new IllegalArgumentException("ReadablePartial objects must have the same set of fields");
    }
    for (int i = 0, isize = start.size(); i < isize; i++) {
        if (start.getFieldType(i) != end.getFieldType(i)) {
            throw new IllegalArgumentException("ReadablePartial objects must have the same set of fields");
        }
    }
    if (DateTimeUtils.isContiguous(start) == false) {
        throw new IllegalArgumentException("ReadablePartial objects must be contiguous");
    }
    Chronology chrono = DateTimeUtils.getChronology(start.getChronology()).withUTC();
    int[] values = chrono.get(zeroInstance, chrono.set(start, 0L), chrono.set(end, 0L));
    return values[0];
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:32,代码来源:BaseSingleFieldPeriod.java

示例11: standardPeriodIn

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
/**
 * Creates a new instance representing the number of complete standard length units
 * in the specified period.
 * <p>
 * This factory method converts all fields from the period to hours using standardised
 * durations for each field. Only those fields which have a precise duration in
 * the ISO UTC chronology can be converted.
 * <ul>
 * <li>One week consists of 7 days.
 * <li>One day consists of 24 hours.
 * <li>One hour consists of 60 minutes.
 * <li>One minute consists of 60 seconds.
 * <li>One second consists of 1000 milliseconds.
 * </ul>
 * Months and Years are imprecise and periods containing these values cannot be converted.
 *
 * @param period  the period to get the number of hours from, must not be null
 * @param millisPerUnit  the number of milliseconds in one standard unit of this period
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
protected static int standardPeriodIn(ReadablePeriod period, long millisPerUnit) {
    if (period == null) {
        return 0;
    }
    Chronology iso = ISOChronology.getInstanceUTC();
    long duration = 0L;
    for (int i = 0; i < period.size(); i++) {
        int value = period.getValue(i);
        if (value != 0) {
            DurationField field = period.getFieldType(i).getField(iso);
            if (field.isPrecise() == false) {
                throw new IllegalArgumentException(
                        "Cannot convert period to duration as " + field.getName() +
                        " is not precise in the period " + period);
            }
            duration = FieldUtils.safeAdd(duration, FieldUtils.safeMultiply(field.getUnitMillis(), value));
        }
    }
    return FieldUtils.safeToInt(duration / millisPerUnit);
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:41,代码来源:BaseSingleFieldPeriod.java

示例12: addPeriodInto

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
/**
 * Adds the fields from another period.
 * 
 * @param values  the array of values to update
 * @param period  the period to add from, not null
 * @return the updated values
 * @throws IllegalArgumentException if an unsupported field's value is non-zero
 */
protected int[] addPeriodInto(int[] values, ReadablePeriod period) {
    for (int i = 0, isize = period.size(); i < isize; i++) {
        DurationFieldType type = period.getFieldType(i);
        int value = period.getValue(i);
        if (value != 0) {
            int index = indexOf(type);
            if (index == -1) {
                throw new IllegalArgumentException(
                    "Period does not support field '" + type.getName() + "'");
            } else {
                values[index] = FieldUtils.safeAdd(getValue(index), value);
            }
        }
    }
    return values;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:25,代码来源:BasePeriod.java

示例13: calculatePrintedLength

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
public int calculatePrintedLength(ReadablePeriod period, Locale locale) {
    PeriodPrinter before = iBeforePrinter;
    PeriodPrinter after = iAfterPrinter;
    
    int sum = before.calculatePrintedLength(period, locale)
            + after.calculatePrintedLength(period, locale);
    
    if (iUseBefore) {
        if (before.countFieldsToPrint(period, 1, locale) > 0) {
            if (iUseAfter) {
                int afterCount = after.countFieldsToPrint(period, 2, locale);
                if (afterCount > 0) {
                    sum += (afterCount > 1 ? iText : iFinalText).length();
                }
            } else {
                sum += iText.length();
            }
        }
    } else if (iUseAfter && after.countFieldsToPrint(period, 1, locale) > 0) {
        sum += iText.length();
    }
    
    return sum;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:25,代码来源:PeriodFormatterBuilder.java

示例14: printTo

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
public void printTo(StringBuffer buf, ReadablePeriod period, Locale locale) {
    PeriodPrinter before = iBeforePrinter;
    PeriodPrinter after = iAfterPrinter;
    
    before.printTo(buf, period, locale);
    if (iUseBefore) {
        if (before.countFieldsToPrint(period, 1, locale) > 0) {
            if (iUseAfter) {
                int afterCount = after.countFieldsToPrint(period, 2, locale);
                if (afterCount > 0) {
                    buf.append(afterCount > 1 ? iText : iFinalText);
                }
            } else {
                buf.append(iText);
            }
        }
    } else if (iUseAfter && after.countFieldsToPrint(period, 1, locale) > 0) {
        buf.append(iText);
    }
    after.printTo(buf, period, locale);
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:22,代码来源:PeriodFormatterBuilder.java

示例15: get

import org.joda.time.ReadablePeriod; //导入依赖的package包/类
/**
 * Gets the values of a period from an interval.
 *
 * @param period  the period instant to use
 * @param duration  the duration to query
 * @return the values of the period extracted from the duration
 */
public int[] get(ReadablePeriod period, long duration) {
    int size = period.size();
    int[] values = new int[size];
    if (duration != 0) {
        long current = 0;
        for (int i = 0; i < size; i++) {
            DurationField field = period.getFieldType(i).getField(this);
            if (field.isPrecise()) {
                int value = field.getDifference(duration, current);
                current = field.add(current, value);
                values[i] = value;
            }
        }
    }
    return values;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:24,代码来源:BaseChronology.java


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