MCPcopy Create free account
hub / github.com/ReadyTalk/avian / parseIntoFields

Method parseIntoFields

classpath/java/util/Calendar.java:130–158  ·  view source on GitHub ↗
(long timeInMillis)

Source from the content-addressed store, hash-verified

128 }
129
130 private void parseIntoFields(long timeInMillis) {
131 long days = timeInMillis / MILLIS_PER_DAY;
132 /* convert days since Jan 1, 1970 to days since Jan 1, 1968 */
133 days += DAYS_TO_EPOCH;
134 long years = 4 * days / 1461; /* days/365.25 = 4*days/(4*365.25) */
135 int year = (int)(EPOCH_LEAP_YEAR + years);
136 days -= 365 * years + years / 4;
137 if (!isLeapYear(year)) days--;
138
139 int month=0;
140 int leapIndex = isLeapYear(year) ? 1 : 0;
141 while (days >= DAYS_IN_MONTH[leapIndex][month]) {
142 days -= DAYS_IN_MONTH[leapIndex][month++];
143 }
144 days++;
145
146 int remainder = (int)(timeInMillis % MILLIS_PER_DAY);
147 int hour = remainder / MILLIS_PER_HOUR;
148 remainder = remainder % MILLIS_PER_HOUR;
149 int minute = remainder / MILLIS_PER_MINUTE;
150 remainder = remainder % MILLIS_PER_MINUTE;
151 int second = remainder / MILLIS_PER_SECOND;
152 fields[YEAR] = year;
153 fields[MONTH] = month;
154 fields[DAY_OF_MONTH] = (int)days;
155 fields[HOUR_OF_DAY] = hour;
156 fields[MINUTE] = minute;
157 fields[SECOND] = second;
158 }
159
160 public void roll(int field, boolean up) {
161 // todo

Callers 2

MyCalendarMethod · 0.95
setTimeMethod · 0.95

Calls 1

isLeapYearMethod · 0.95

Tested by

no test coverage detected