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


Java DateTimeConstants.MILLIS_PER_DAY属性代码示例

本文整理汇总了Java中org.joda.time.DateTimeConstants.MILLIS_PER_DAY属性的典型用法代码示例。如果您正苦于以下问题:Java DateTimeConstants.MILLIS_PER_DAY属性的具体用法?Java DateTimeConstants.MILLIS_PER_DAY怎么用?Java DateTimeConstants.MILLIS_PER_DAY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.joda.time.DateTimeConstants的用法示例。


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

示例1: testRoundingRandom

/**
 * Randomized test on TimeUnitRounding. Test uses random
 * {@link DateTimeUnit} and {@link DateTimeZone} and often (50% of the time)
 * chooses test dates that are exactly on or close to offset changes (e.g.
 * DST) in the chosen time zone.
 *
 * It rounds the test date down and up and performs various checks on the
 * rounding unit interval that is defined by this. Assumptions tested are
 * described in
 * {@link #assertInterval(long, long, long, Rounding, DateTimeZone)}
 */
public void testRoundingRandom() {
    for (int i = 0; i < 1000; ++i) {
        DateTimeUnit timeUnit = randomTimeUnit();
        DateTimeZone tz = randomDateTimeZone();
        Rounding rounding = new Rounding.TimeUnitRounding(timeUnit, tz);
        long date = Math.abs(randomLong() % (2 * (long) 10e11)); // 1970-01-01T00:00:00Z - 2033-05-18T05:33:20.000+02:00
        long unitMillis = timeUnit.field(tz).getDurationField().getUnitMillis();
        if (randomBoolean()) {
            nastyDate(date, tz, unitMillis);
        }
        final long roundedDate = rounding.round(date);
        final long nextRoundingValue = rounding.nextRoundingValue(roundedDate);

        assertInterval(roundedDate, date, nextRoundingValue, rounding, tz);

        // check correct unit interval width for units smaller than a day, they should be fixed size except for transitions
        if (unitMillis <= DateTimeConstants.MILLIS_PER_DAY) {
            // if the interval defined didn't cross timezone offset transition, it should cover unitMillis width
            if (tz.getOffset(roundedDate - 1) == tz.getOffset(nextRoundingValue + 1)) {
                assertThat("unit interval width not as expected for [" + timeUnit + "], [" + tz + "] at "
                        + new DateTime(roundedDate), nextRoundingValue - roundedDate, equalTo(unitMillis));
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:TimeZoneRoundingTests.java

示例2: millisPerUnit

private static int millisPerUnit(String unit) {
  switch (Ascii.toLowerCase(unit)) {
    case "d":
      return DateTimeConstants.MILLIS_PER_DAY;
    case "h":
      return DateTimeConstants.MILLIS_PER_HOUR;
    case "m":
      return DateTimeConstants.MILLIS_PER_MINUTE;
    case "s":
      return DateTimeConstants.MILLIS_PER_SECOND;
    case "ms":
      return 1;
    default:
      throw new IllegalArgumentException("Unknown duration unit " + unit);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:pubsub,代码行数:16,代码来源:Driver.java

示例3: run

@Scheduled(fixedRate=DateTimeConstants.MILLIS_PER_DAY)
public void run() {
    LocalDateTime lastImport = service.getLastImportDate(PublicationSource.ARXIV);
    for (String feedKey : FEEDS) {
        SyndFeedInput input = new SyndFeedInput();
        try {
            SyndFeed feed = input.build(new XmlReader(new URL(ROOT_RSS_URL + feedKey)));
            List<String> ids = new ArrayList<String>(feed.getEntries().size());
            for (SyndEntry entry : feed.getEntries()) {
                ids.add(entry.getLink().replace(URI_PREFIX, ""));
            }
            
            URL url = new URL("http://export.arxiv.org/api/query?id_list=" + joiner.join(ids) + "&max_results=100");
            try (InputStream inputStream = url.openStream()) {
                List<Publication> publications = extractPublications(inputStream, lastImport, ids.size());
                publications = publications.stream().filter(p -> p.getCreated().isAfter(lastImport)).collect(Collectors.toList());
                logger.info("Obtained publications from arxiv for category {}: {}", feedKey, publications.size());
                service.storePublication(publications);
            }
            
        } catch (IllegalArgumentException | FeedException | IOException e) {
            logger.error("Problem getting arxiv RSS feed", e);
        }
    }
}
 
开发者ID:Glamdring,项目名称:scientific-publishing,代码行数:25,代码来源:ArxivImporter.java

示例4: calculateFirstDayOfYearMillis

long calculateFirstDayOfYearMillis(int year) {
    // Java epoch is 1970-01-01 Gregorian which is 1969-12-19 Julian.
    // Calculate relative to the nearest leap year and account for the
    // difference later.

    int relativeYear = year - 1968;
    int leapYears;
    if (relativeYear <= 0) {
        // Add 3 before shifting right since /4 and >>2 behave differently
        // on negative numbers.
        leapYears = (relativeYear + 3) >> 2;
    } else {
        leapYears = relativeYear >> 2;
        // For post 1968 an adjustment is needed as jan1st is before leap day
        if (!isLeapYear(year)) {
            leapYears++;
        }
    }
    
    long millis = (relativeYear * 365L + leapYears) * (long)DateTimeConstants.MILLIS_PER_DAY;

    // Adjust to account for difference between 1968-01-01 and 1969-12-19.

    return millis - (366L + 352) * DateTimeConstants.MILLIS_PER_DAY;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:25,代码来源:JulianChronology.java

示例5: calculateFirstDayOfYearMillis

long calculateFirstDayOfYearMillis(int year) {
    // Java epoch is 1970-01-01 Gregorian which is 1686-04-23 Coptic.
    // Calculate relative to the nearest leap year and account for the
    // difference later.

    int relativeYear = year - 1687;
    int leapYears;
    if (relativeYear <= 0) {
        // Add 3 before shifting right since /4 and >>2 behave differently
        // on negative numbers.
        leapYears = (relativeYear + 3) >> 2;
    } else {
        leapYears = relativeYear >> 2;
        // For post 1687 an adjustment is needed as jan1st is before leap day
        if (!isLeapYear(year)) {
            leapYears++;
        }
    }
    
    long millis = (relativeYear * 365L + leapYears)
        * (long)DateTimeConstants.MILLIS_PER_DAY;

    // Adjust to account for difference between 1687-01-01 and 1686-04-23.

    return millis + (365L - 112) * DateTimeConstants.MILLIS_PER_DAY;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:26,代码来源:CopticChronology.java

示例6: getDayOfWeek

/**
 * @param instant millis from 1970-01-01T00:00:00Z
 */
int getDayOfWeek(long instant) {
    // 1970-01-01 is day of week 4, Thursday.

    long daysSince19700101;
    if (instant >= 0) {
        daysSince19700101 = instant / DateTimeConstants.MILLIS_PER_DAY;
    } else {
        daysSince19700101 = (instant - (DateTimeConstants.MILLIS_PER_DAY - 1))
            / DateTimeConstants.MILLIS_PER_DAY;
        if (daysSince19700101 < -3) {
            return 7 + (int) ((daysSince19700101 + 4) % 7);
        }
    }

    return 1 + (int) ((daysSince19700101 + 3) % 7);
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:19,代码来源:BasicChronology.java

示例7: calculateFirstDayOfYearMillis

long calculateFirstDayOfYearMillis(int year) {
    // Initial value is just temporary.
    int leapYears = year / 100;
    if (year < 0) {
        // Add 3 before shifting right since /4 and >>2 behave differently
        // on negative numbers. When the expression is written as
        // (year / 4) - (year / 100) + (year / 400),
        // it works for both positive and negative values, except this optimization
        // eliminates two divisions.
        leapYears = ((year + 3) >> 2) - leapYears + ((leapYears + 3) >> 2) - 1;
    } else {
        leapYears = (year >> 2) - leapYears + (leapYears >> 2);
        if (isLeapYear(year)) {
            leapYears--;
        }
    }

    return (year * 365L + (leapYears - DAYS_0000_TO_1970)) * DateTimeConstants.MILLIS_PER_DAY;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:19,代码来源:GregorianChronology.java

示例8: getYearDifference

long getYearDifference(long minuendInstant, long subtrahendInstant) {
    int minuendYear = getYear(minuendInstant);
    int subtrahendYear = getYear(subtrahendInstant);

    // Inlined remainder method to avoid duplicate calls to get.
    long minuendRem = minuendInstant - getYearMillis(minuendYear);
    long subtrahendRem = subtrahendInstant - getYearMillis(subtrahendYear);

    // Balance leap year differences on remainders.
    if (subtrahendRem >= FEB_29) {
        if (isLeapYear(subtrahendYear)) {
            if (!isLeapYear(minuendYear)) {
                subtrahendRem -= DateTimeConstants.MILLIS_PER_DAY;
            }
        } else if (minuendRem >= FEB_29 && isLeapYear(minuendYear)) {
            minuendRem -= DateTimeConstants.MILLIS_PER_DAY;
        }
    }

    int difference = minuendYear - subtrahendYear;
    if (minuendRem < subtrahendRem) {
        difference--;
    }
    return difference;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:25,代码来源:BasicGJChronology.java

示例9: calculateFirstDayOfYearMillis

long calculateFirstDayOfYearMillis(int year) {
    // Java epoch is 1970-01-01 Gregorian which is 1962-04-23 Ethiopic.
    // Calculate relative to the nearest leap year and account for the
    // difference later.

    int relativeYear = year - 1963;
    int leapYears;
    if (relativeYear <= 0) {
        // Add 3 before shifting right since /4 and >>2 behave differently
        // on negative numbers.
        leapYears = (relativeYear + 3) >> 2;
    } else {
        leapYears = relativeYear >> 2;
        // For post 1963 an adjustment is needed as jan1st is before leap day
        if (!isLeapYear(year)) {
            leapYears++;
        }
    }
    
    long millis = (relativeYear * 365L + leapYears)
        * (long)DateTimeConstants.MILLIS_PER_DAY;

    // Adjust to account for difference between 1963-01-01 and 1962-04-23.

    return millis + (365L - 112) * DateTimeConstants.MILLIS_PER_DAY;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:26,代码来源:EthiopicChronology.java

示例10: addInt

@Override
public void addInt(int value) {
  if (value > ParquetReaderUtility.DATE_CORRUPTION_THRESHOLD) {
    holder.value = (value - ParquetReaderUtility.CORRECT_CORRUPT_DATE_SHIFT) * DateTimeConstants.MILLIS_PER_DAY;
  } else {
    holder.value = value * (long) DateTimeConstants.MILLIS_PER_DAY;
  }
  writer.write(holder);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:9,代码来源:ParquetGroupConverter.java

示例11: getDateTimeValueFromBinary

/**
* @param binaryTimeStampValue
*          hive, impala timestamp values with nanoseconds precision
*          are stored in parquet Binary as INT96 (12 constant bytes)
*
* @return  Unix Timestamp - the number of milliseconds since January 1, 1970, 00:00:00 GMT
*          represented by @param binaryTimeStampValue .
*/
 public static long getDateTimeValueFromBinary(Binary binaryTimeStampValue) {
   // This method represents binaryTimeStampValue as ByteBuffer, where timestamp is stored as sum of
   // julian day number (32-bit) and nanos of day (64-bit)
   NanoTime nt = NanoTime.fromBinary(binaryTimeStampValue);
   int julianDay = nt.getJulianDay();
   long nanosOfDay = nt.getTimeOfDayNanos();
   return (julianDay - JULIAN_DAY_NUMBER_FOR_UNIX_EPOCH) * DateTimeConstants.MILLIS_PER_DAY
       + nanosOfDay / NANOS_PER_MILLISECOND;
 }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:ParquetReaderUtility.java

示例12: getDuration

public static Duration getDuration(LocalDateTime start, LocalDateTime end) {
    long startMillis = start.getMillisOfDay();
    long endMillis = end.getMillisOfDay();

    if (endMillis <= startMillis)
        endMillis = endMillis + DateTimeConstants.MILLIS_PER_DAY;

    return new Duration(endMillis - startMillis);
}
 
开发者ID:modymapp,项目名称:modym-client-java,代码行数:9,代码来源:ModymDateTimeUtils.java

示例13: getDateTimeValueFromBinary

/**
* @param binaryTimeStampValue
*          hive, impala timestamp values with nanoseconds precision
*          are stored in parquet Binary as INT96 (12 constant bytes)
* @param retainLocalTimezone
*          parquet files don't keep local timeZone according to the
*          <a href="https://github.com/Parquet/parquet-format/blob/master/LogicalTypes.md#timestamp">Parquet spec</a>,
*          but some tools (hive, for example) retain local timezone for parquet files by default
*          Note: Impala doesn't retain local timezone by default
* @return  Timestamp in milliseconds - the number of milliseconds since January 1, 1970, 00:00:00 GMT
*          represented by @param binaryTimeStampValue.
*          The nanos precision is cut to millis. Therefore the length of single timestamp value is
*          {@value NullableTimeStampHolder#WIDTH} bytes instead of 12 bytes.
*/
 public static long getDateTimeValueFromBinary(Binary binaryTimeStampValue, boolean retainLocalTimezone) {
   // This method represents binaryTimeStampValue as ByteBuffer, where timestamp is stored as sum of
   // julian day number (4 bytes) and nanos of day (8 bytes)
   NanoTime nt = NanoTime.fromBinary(binaryTimeStampValue);
   int julianDay = nt.getJulianDay();
   long nanosOfDay = nt.getTimeOfDayNanos();
   long dateTime = (julianDay - JULIAN_DAY_NUMBER_FOR_UNIX_EPOCH) * DateTimeConstants.MILLIS_PER_DAY
       + nanosOfDay / NANOS_PER_MILLISECOND;
   if (retainLocalTimezone) {
     return DateTimeZone.getDefault().convertUTCToLocal(dateTime);
   } else {
     return dateTime;
   }
 }
 
开发者ID:axbaretto,项目名称:drill,代码行数:28,代码来源:ParquetReaderUtility.java

示例14: convertToDrillDateValue

private static long convertToDrillDateValue(int dateValue, boolean isDateCorrect) {
  // See DRILL-4203 for the background regarding date type corruption issue in Drill CTAS prior to 1.9.0 release.
  if (isDateCorrect) {
    return dateValue * (long) DateTimeConstants.MILLIS_PER_DAY;
  } else {
    return (dateValue - ParquetReaderUtility.CORRECT_CORRUPT_DATE_SHIFT) * DateTimeConstants.MILLIS_PER_DAY;
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:8,代码来源:ParquetFooterStatCollector.java

示例15: getFirstWeekOfYearMillis

/**
 * Get the millis for the first week of a year.
 *
 * @param year  the year to use
 * @return millis
 */
long getFirstWeekOfYearMillis(int year) {
    long jan1millis = getYearMillis(year);
    int jan1dayOfWeek = getDayOfWeek(jan1millis);
    
    if (jan1dayOfWeek > (8 - iMinDaysInFirstWeek)) {
        // First week is end of previous year because it doesn't have enough days.
        return jan1millis + (8 - jan1dayOfWeek)
            * (long)DateTimeConstants.MILLIS_PER_DAY;
    } else {
        // First week is start of this year because it has enough days.
        return jan1millis - (jan1dayOfWeek - 1)
            * (long)DateTimeConstants.MILLIS_PER_DAY;
    }
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:20,代码来源:BasicChronology.java


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