List of usage examples for java.time LocalTime getSecond
public int getSecond()
From source file:Main.java
public static void main(String[] args) { LocalTime l = LocalTime.now(); System.out.println(l.getSecond()); }
From source file:Main.java
public static void main(String[] args) { LocalTime time = LocalTime.of(15, 30, 23, 234); // 15:30:00 System.out.println(time.getHour()); // 15 System.out.println(time.getMinute()); // 30 System.out.println(time.getSecond()); // 23 System.out.println(time.getNano()); // 234 System.out.println(time.toSecondOfDay()); // 55823 System.out.println(time.toNanoOfDay()); // 55823000000234 }
From source file:com.haulmont.cuba.web.widgets.CubaTimeField.java
protected LocalTime applyResolutionToValue(LocalTime value) { if (value == null) { return null; }// w ww. j ava2 s . co m LocalTime result = LocalTime.MIDNIGHT; List<TimeResolution> resolutions = getResolutionsHigherOrEqualTo(getResolution()) .collect(Collectors.toList()); for (TimeResolution resolution : resolutions) { switch (resolution) { case HOUR: result = result.withHour(value.getHour()); break; case MINUTE: result = result.withMinute(value.getMinute()); break; case SECOND: result = result.withSecond(value.getSecond()); break; default: throw new IllegalArgumentException("Cannot detect resolution type"); } } return result; }
From source file:nu.yona.server.analysis.service.ActivityServiceTest.java
@Test public void getUserDayActivityDetail_activityPresent_resultWithActivity() { ZonedDateTime today = getDayStartTime(ZonedDateTime.now(userAnonZone)); ZonedDateTime yesterday = today.minusDays(1); LocalTime activityStartTimeOnDay = LocalTime.parse("20:14:57"); LocalTime activityEndTimeOnDay = LocalTime.parse("20:21:00"); int hour = 20; int[] expectedSpread = getEmptySpread(); expectedSpread[hour * 4] = 1;//from ww w . j av a 2 s.co m expectedSpread[hour * 4 + 1] = 6; // gambling goal was created 2 weeks ago, see above // mock some activity on yesterday DayActivity yesterdayRecordedActivity = DayActivity.createInstance(userAnonEntity, gamblingGoal, userAnonZone, yesterday.toLocalDate()); ZonedDateTime activityStartTime = yesterday.withHour(activityStartTimeOnDay.getHour()) .withMinute(activityStartTimeOnDay.getMinute()).withSecond(activityStartTimeOnDay.getSecond()); ZonedDateTime activityEndTime = yesterday.withHour(activityEndTimeOnDay.getHour()) .withMinute(activityEndTimeOnDay.getMinute()).withSecond(activityEndTimeOnDay.getSecond()); Activity recordedActivity = Activity.createInstance(userAnonZone, activityStartTime.toLocalDateTime(), activityEndTime.toLocalDateTime(), Optional.empty()); yesterdayRecordedActivity.addActivity(recordedActivity); when(mockDayActivityRepository.findOne(userAnonId, yesterday.toLocalDate(), gamblingGoal.getId())) .thenReturn(yesterdayRecordedActivity); DayActivityDto activityDay = service.getUserDayActivityDetail(userId, yesterday.toLocalDate(), gamblingGoal.getId()); verify(mockDayActivityRepository, times(1)).findOne(userAnonId, yesterday.toLocalDate(), gamblingGoal.getId()); assertThat(activityDay.getSpread(), equalTo(Arrays.asList(ArrayUtils.toObject((expectedSpread))))); }
From source file:org.dozer.converters.LocalTimeConverter.java
@Override public Object convert(Class destClass, Object srcObj) { LocalTime convertedValue = null; try {//from www. j av a2 s .c om if (srcObj instanceof String) { convertedValue = LocalTime.parse((String) srcObj); } else { LocalTime srcObject = (LocalTime) srcObj; convertedValue = LocalTime.of(srcObject.getHour(), srcObject.getMinute(), srcObject.getSecond(), srcObject.getNano()); } } catch (Exception e) { MappingUtils.throwMappingException("Cannot convert [" + srcObj + "] to LocalTime.", e); } return convertedValue; }