use of java.time.ZoneId in project teammates by TEAMMATES.
the class CoursesDb method makeAttributes.
@Override
protected CourseAttributes makeAttributes(Course entity) {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, entity);
ZoneId courseTimeZone;
try {
courseTimeZone = ZoneId.of(entity.getTimeZone());
} catch (DateTimeException e) {
log.severe("Timezone '" + entity.getTimeZone() + "' of course '" + entity.getUniqueId() + "' is not supported. UTC will be used instead.");
courseTimeZone = Const.DEFAULT_TIME_ZONE;
}
return CourseAttributes.builder(entity.getUniqueId(), entity.getName(), courseTimeZone).withCreatedAt(entity.getCreatedAt()).build();
}
use of java.time.ZoneId in project tilesfx by HanSolo.
the class Tile method getTime.
/**
* Returns the current time of the clock.
* @return the current time of the clock
*/
public ZonedDateTime getTime() {
if (null == time) {
ZonedDateTime now = ZonedDateTime.now();
time = new ObjectPropertyBase<ZonedDateTime>(now) {
@Override
protected void invalidated() {
zoneId = get().getZone();
fireTileEvent(RECALC_EVENT);
if (!isRunning() && isAnimated()) {
long animationDuration = getAnimationDuration();
timeline.stop();
final KeyValue KEY_VALUE = new KeyValue(currentTime, now.toEpochSecond());
final KeyFrame KEY_FRAME = new KeyFrame(javafx.util.Duration.millis(animationDuration), KEY_VALUE);
timeline.getKeyFrames().setAll(KEY_FRAME);
timeline.setOnFinished(e -> fireTileEvent(FINISHED_EVENT));
timeline.play();
} else {
currentTime.set(now.toEpochSecond());
fireTileEvent(FINISHED_EVENT);
}
}
@Override
public Object getBean() {
return Tile.this;
}
@Override
public String getName() {
return "time";
}
};
}
return time.get();
}
use of java.time.ZoneId in project muikku by otavanopisto.
the class PyramusGradingSchoolDataBridge method fromDateToOffsetDateTime.
private OffsetDateTime fromDateToOffsetDateTime(Date date) {
Instant instant = date.toInstant();
ZoneId systemId = ZoneId.systemDefault();
ZoneOffset offset = systemId.getRules().getOffset(instant);
return date.toInstant().atOffset(offset);
}
use of java.time.ZoneId in project portfolio by buchen.
the class TimelineChart method paintTimeGrid.
private void paintTimeGrid(PaintEvent e) {
IAxis xAxis = getAxisSet().getXAxis(0);
Range range = xAxis.getRange();
ZoneId zoneId = ZoneId.systemDefault();
LocalDate start = Instant.ofEpochMilli((long) range.lower).atZone(zoneId).toLocalDate();
LocalDate end = Instant.ofEpochMilli((long) range.upper).atZone(zoneId).toLocalDate();
LocalDate cursor = start.getDayOfMonth() == 1 ? start : start.plusMonths(1).withDayOfMonth(1);
Period period;
DateTimeFormatter format;
long days = ChronoUnit.DAYS.between(start, end);
if (days < 250) {
period = Period.ofMonths(1);
// $NON-NLS-1$
format = DateTimeFormatter.ofPattern("MMMM yyyy");
} else if (days < 800) {
period = Period.ofMonths(3);
// $NON-NLS-1$
format = DateTimeFormatter.ofPattern("QQQ yyyy");
cursor = cursor.plusMonths((12 - cursor.getMonthValue() + 1) % 3);
} else if (days < 1200) {
period = Period.ofMonths(6);
// $NON-NLS-1$
format = DateTimeFormatter.ofPattern("QQQ yyyy");
cursor = cursor.plusMonths((12 - cursor.getMonthValue() + 1) % 6);
} else {
period = Period.ofYears(days > 5000 ? 2 : 1);
// $NON-NLS-1$
format = DateTimeFormatter.ofPattern("yyyy");
if (cursor.getMonthValue() > 1)
cursor = cursor.plusYears(1).withDayOfYear(1);
}
while (cursor.isBefore(end)) {
int y = xAxis.getPixelCoordinate((double) cursor.atStartOfDay(zoneId).toInstant().toEpochMilli());
e.gc.drawLine(y, 0, y, e.height);
e.gc.drawText(format.format(cursor), y + 5, 5);
cursor = cursor.plus(period);
}
}
use of java.time.ZoneId in project portfolio by buchen.
the class TimelineChart method toJavaUtilDate.
public static Date[] toJavaUtilDate(LocalDate[] dates) {
ZoneId zoneId = ZoneId.systemDefault();
Date[] answer = new Date[dates.length];
for (int ii = 0; ii < answer.length; ii++) answer[ii] = Date.from(dates[ii].atStartOfDay().atZone(zoneId).toInstant());
return answer;
}
Aggregations