Java Code Examples for org.joda.time.base.BaseSingleFieldPeriod#standardPeriodIn()

The following examples show how to use org.joda.time.base.BaseSingleFieldPeriod#standardPeriodIn() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestBaseSingleFieldPeriod.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public static int standardPeriodIn(ReadablePeriod period, long millisPerUnit) {
    return BaseSingleFieldPeriod.standardPeriodIn(period, millisPerUnit);
}
 
Example 2
Source File: TestBaseSingleFieldPeriod.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public static int standardPeriodIn(ReadablePeriod period, long millisPerUnit) {
    return BaseSingleFieldPeriod.standardPeriodIn(period, millisPerUnit);
}
 
Example 3
Source File: Minutes.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>Minutes</code> representing the number of complete
 * standard length minutes in the specified period.
 * <p>
 * This factory method converts all fields from the period to minutes 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 minutes from, null returns zero
 * @return the period in minutes
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
public static Minutes standardMinutesIn(ReadablePeriod period) {
    int amount = BaseSingleFieldPeriod.standardPeriodIn(period, DateTimeConstants.MILLIS_PER_MINUTE);
    return Minutes.minutes(amount);
}
 
Example 4
Source File: Weeks.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>Weeks</code> representing the number of complete
 * standard length weeks 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 weeks.
 * <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, null returns zero
 * @return the period in weeks
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
public static Weeks standardWeeksIn(ReadablePeriod period) {
    int amount = BaseSingleFieldPeriod.standardPeriodIn(period, DateTimeConstants.MILLIS_PER_WEEK);
    return Weeks.weeks(amount);
}
 
Example 5
Source File: Seconds.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>Seconds</code> representing the number of complete
 * standard length seconds 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 seconds.
 * <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, null returns zero
 * @return the period in seconds
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
public static Seconds standardSecondsIn(ReadablePeriod period) {
    int amount = BaseSingleFieldPeriod.standardPeriodIn(period, DateTimeConstants.MILLIS_PER_SECOND);
    return Seconds.seconds(amount);
}
 
Example 6
Source File: Days.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>Days</code> representing the number of complete
 * standard length days 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, null returns zero
 * @return the period in days
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
public static Days standardDaysIn(ReadablePeriod period) {
    int amount = BaseSingleFieldPeriod.standardPeriodIn(period, DateTimeConstants.MILLIS_PER_DAY);
    return Days.days(amount);
}
 
Example 7
Source File: Hours.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>Hours</code> representing the number of complete
 * standard length hours 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, null returns zero
 * @return the period in hours
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
public static Hours standardHoursIn(ReadablePeriod period) {
    int amount = BaseSingleFieldPeriod.standardPeriodIn(period, DateTimeConstants.MILLIS_PER_HOUR);
    return Hours.hours(amount);
}
 
Example 8
Source File: Minutes.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>Minutes</code> representing the number of complete
 * standard length minutes in the specified period.
 * <p>
 * This factory method converts all fields from the period to minutes 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 minutes from, null returns zero
 * @return the period in minutes
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
public static Minutes standardMinutesIn(ReadablePeriod period) {
    int amount = BaseSingleFieldPeriod.standardPeriodIn(period, DateTimeConstants.MILLIS_PER_MINUTE);
    return Minutes.minutes(amount);
}
 
Example 9
Source File: Weeks.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>Weeks</code> representing the number of complete
 * standard length weeks 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 weeks.
 * <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, null returns zero
 * @return the period in weeks
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
public static Weeks standardWeeksIn(ReadablePeriod period) {
    int amount = BaseSingleFieldPeriod.standardPeriodIn(period, DateTimeConstants.MILLIS_PER_WEEK);
    return Weeks.weeks(amount);
}
 
Example 10
Source File: Seconds.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>Seconds</code> representing the number of complete
 * standard length seconds 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 seconds.
 * <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, null returns zero
 * @return the period in seconds
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
public static Seconds standardSecondsIn(ReadablePeriod period) {
    int amount = BaseSingleFieldPeriod.standardPeriodIn(period, DateTimeConstants.MILLIS_PER_SECOND);
    return Seconds.seconds(amount);
}
 
Example 11
Source File: Days.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>Days</code> representing the number of complete
 * standard length days 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, null returns zero
 * @return the period in days
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
public static Days standardDaysIn(ReadablePeriod period) {
    int amount = BaseSingleFieldPeriod.standardPeriodIn(period, DateTimeConstants.MILLIS_PER_DAY);
    return Days.days(amount);
}
 
Example 12
Source File: Hours.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a new <code>Hours</code> representing the number of complete
 * standard length hours 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, null returns zero
 * @return the period in hours
 * @throws IllegalArgumentException if the period contains imprecise duration values
 */
public static Hours standardHoursIn(ReadablePeriod period) {
    int amount = BaseSingleFieldPeriod.standardPeriodIn(period, DateTimeConstants.MILLIS_PER_HOUR);
    return Hours.hours(amount);
}