List of usage examples for java.time ZonedDateTime getNano
public int getNano()
From source file:Main.java
public static void main(String[] args) { ZonedDateTime dateTime = ZonedDateTime.now(); System.out.println(dateTime.getNano()); }
From source file:com.epam.parso.impl.CSVDataWriterImpl.java
/** * The function to convert a Java 8 LocalDateTime into a string according to the format used. * * @param currentDate the LocalDateTime to convert. * @param format the string with the format that must belong to the set of * {@link CSVDataWriterImpl#DATE_OUTPUT_FORMAT_STRINGS} mapping keys. * @return the string that corresponds to the date in the format used. *///from ww w . j a v a2 s .c o m protected static String convertLocalDateTimeElementToString(LocalDateTime currentDate, String format) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_OUTPUT_FORMAT_STRINGS.get(format)); String valueToPrint = ""; ZonedDateTime zonedDateTime = currentDate.atZone(ZoneOffset.UTC); if (zonedDateTime.toInstant().toEpochMilli() != 0 && zonedDateTime.getNano() != 0) { valueToPrint = formatter.format(currentDate); } return valueToPrint; }
From source file:org.caratarse.auth.model.dao.UserAttributesTest.java
@Test public void lastUserAttribute() { User user = retrieveUserWithAttributes(); Attribute attribute = user.getUserAttributes().get("last"); assertTrue(attribute instanceof DateTimeAttribute); assertThat(attribute.getName(), is("last")); final Date value = new Date(((Date) attribute.getValue()).getTime()); ZonedDateTime v = value.toInstant().atZone(ZoneId.of("UTC")); assertThat(v.getDayOfMonth(), is(20)); assertThat(v.getMonthValue(), is(11)); assertThat(v.getYear(), is(2015));/*from w ww . j av a 2s.c om*/ assertThat(v.getHour(), is(12)); assertThat(v.getMinute(), is(11)); assertThat(v.getSecond(), is(10)); assertThat(v.getNano(), is(999000000)); }