Java Code Examples for java.time.LocalDateTime#getSecond()
The following examples show how to use
java.time.LocalDateTime#getSecond() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: tez File: DagManifesFileScanner.java License: Apache License 2.0 | 6 votes |
private boolean loadMore() throws IOException { LocalDateTime now = manifestLogger.getNow(); LocalDate today = now.toLocalDate(); String todayDir = manifestLogger.getDirForDate(today); loadNewFiles(todayDir); while (newFiles.isEmpty()) { if (now.getHour() * 3600 + now.getMinute() * 60 + now.getSecond() < syncTime) { // We are in the delay window for today, do not advance date if we are moving from // yesterday. if (scanDir.equals(manifestLogger.getDirForDate(today.minusDays(1)))) { return false; } } String nextDir = manifestLogger.getNextDirectory(scanDir); if (nextDir == null) { return false; } scanDir = nextDir; offsets = new HashMap<>(); retryCount = new HashMap<>(); loadNewFiles(todayDir); } return true; }
Example 2
Source Project: FunnyGuilds File: AbstractTablist.java License: Apache License 2.0 | 6 votes |
@Deprecated protected String putHeaderFooterVars(String text) { String formatted = text; LocalDateTime time = LocalDateTime.now(); int hour = time.getHour(); int minute = time.getMinute(); int second = time.getSecond(); formatted = StringUtils.replace(formatted, "{HOUR}", ChatUtils.appendDigit(hour)); formatted = StringUtils.replace(formatted, "{MINUTE}", ChatUtils.appendDigit(minute)); formatted = StringUtils.replace(formatted, "{SECOND}", ChatUtils.appendDigit(second)); formatted = ChatUtils.colored(formatted); return formatted; }
Example 3
Source Project: Bytecoder File: ZipUtils.java License: Apache License 2.0 | 6 votes |
/** * Converts Java time to DOS time. */ private static long javaToDosTime(long time) { Instant instant = Instant.ofEpochMilli(time); LocalDateTime ldt = LocalDateTime.ofInstant( instant, ZoneId.systemDefault()); int year = ldt.getYear() - 1980; if (year < 0) { return (1 << 21) | (1 << 16); } return (year << 25 | ldt.getMonthValue() << 21 | ldt.getDayOfMonth() << 16 | ldt.getHour() << 11 | ldt.getMinute() << 5 | ldt.getSecond() >> 1) & 0xffffffffL; }
Example 4
Source Project: jackson-modules-java8 File: LocalDateTimeSerializer.java License: Apache License 2.0 | 6 votes |
private final void _serializeAsArrayContents(LocalDateTime value, JsonGenerator g, SerializerProvider provider) throws IOException { g.writeNumber(value.getYear()); g.writeNumber(value.getMonthValue()); g.writeNumber(value.getDayOfMonth()); g.writeNumber(value.getHour()); g.writeNumber(value.getMinute()); final int secs = value.getSecond(); final int nanos = value.getNano(); if ((secs > 0) || (nanos > 0)) { g.writeNumber(secs); if (nanos > 0) { if (useNanoseconds(provider)) { g.writeNumber(nanos); } else { g.writeNumber(value.get(ChronoField.MILLI_OF_SECOND)); } } } }
Example 5
Source Project: dremio-oss File: TimeStampMilliAccessor.java License: Apache License 2.0 | 5 votes |
private Timestamp getTimestamp(int index, TimeZone tz) { if (ac.isNull(index)) { return null; } // The Arrow datetime values are already in UTC, so adjust to the timezone of the calendar passed in to // ensure the reported value is correct according to the JDBC spec. final LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(ac.get(index)), tz.toZoneId()); return new Timestamp(date.getYear() - 1900, date.getMonthValue() - 1, date.getDayOfMonth(), date.getHour(), date.getMinute(), date.getSecond(), date.getNano()); }
Example 6
Source Project: TelegramApi File: BotLogger.java License: MIT License | 5 votes |
private static String dateFormatterForLogs(@NotNull LocalDateTime dateTime) { String dateString = "["; dateString += dateTime.getDayOfMonth() + "_"; dateString += dateTime.getMonthValue() + "_"; dateString += dateTime.getYear() + "_"; dateString += dateTime.getHour() + ":"; dateString += dateTime.getMinute() + ":"; dateString += dateTime.getSecond(); dateString += "] "; return dateString; }
Example 7
Source Project: tablesaw File: PackedLocalDateTime.java License: Apache License 2.0 | 5 votes |
public static long getMillisecondOfDay(long packedLocalDateTime) { LocalDateTime localDateTime = PackedLocalDateTime.asLocalDateTime(packedLocalDateTime); if (localDateTime == null) { throw new IllegalArgumentException("Cannot get millisecond of day for missing value"); } long total = (long) localDateTime.get(ChronoField.MILLI_OF_SECOND); total += localDateTime.getSecond() * 1000; total += localDateTime.getMinute() * 60 * 1000; total += localDateTime.getHour() * 60 * 60 * 1000; return total; }
Example 8
Source Project: tablesaw File: PackedLocalDateTime.java License: Apache License 2.0 | 5 votes |
public static long getMillisecondOfDay(long packedLocalDateTime) { LocalDateTime localDateTime = PackedLocalDateTime.asLocalDateTime(packedLocalDateTime); if (localDateTime == null) { throw new IllegalArgumentException("Cannot get millisecond of day for missing value"); } long total = (long) localDateTime.get(ChronoField.MILLI_OF_SECOND); total += localDateTime.getSecond() * 1000; total += localDateTime.getMinute() * 60 * 1000; total += localDateTime.getHour() * 60 * 60 * 1000; return total; }
Example 9
Source Project: javase File: Java8TestLocalDateTime.java License: MIT License | 5 votes |
public void testLocalDateTime(){ // Get the current date and time LocalDateTime currentTime = LocalDateTime.now(); System.out.println("Current DateTime: " + currentTime); LocalDate date1 = currentTime.toLocalDate(); System.out.println("date1: " + date1); Month month = currentTime.getMonth(); int day = currentTime.getDayOfMonth(); int seconds = currentTime.getSecond(); System.out.println("Month: " + month +"day: " + day +"seconds: " + seconds); LocalDateTime date2 = currentTime.withDayOfMonth(10).withYear(2012); System.out.println("date2: " + date2); //12 december 2014 LocalDate date3 = LocalDate.of(2014, Month.DECEMBER, 12); System.out.println("date3: " + date3); //22 hour 15 minutes LocalTime date4 = LocalTime.of(22, 15); System.out.println("date4: " + date4); //parse a string LocalTime date5 = LocalTime.parse("20:15:30"); System.out.println("date5: " + date5); }
Example 10
Source Project: skUtilities File: ExprDateParsed.java License: GNU General Public License v3.0 | 5 votes |
@Override @Nullable protected Date[] get(Event e) { String s = id.getSingle(e); try { String ddf = new SimpleDateFormat().toPattern(); if (format != null) ddf = format.getSingle(e); LocalDateTime ldt = LocalDateTime.parse(s, DateTimeFormatter.ofPattern(ddf)); return new Date[]{new Date((ldt.toEpochSecond(ZoneOffset.ofTotalSeconds(ldt.getSecond())) + ldt.getSecond()) * 1000)}; } catch (Exception x) { skUtilities.prSysE(x.getMessage(), getClass().getSimpleName(), x); } return null; }
Example 11
Source Project: openjdk-jdk9 File: ZipUtils.java License: GNU General Public License v2.0 | 5 votes |
public static long javaToDosTime(long time) { Instant instant = Instant.ofEpochMilli(time); LocalDateTime ldt = LocalDateTime.ofInstant( instant, ZoneId.systemDefault()); int year = ldt.getYear() - 1980; if (year < 0) { return (1 << 21) | (1 << 16); } return (year << 25 | ldt.getMonthValue() << 21 | ldt.getDayOfMonth() << 16 | ldt.getHour() << 11 | ldt.getMinute() << 5 | ldt.getSecond() >> 1) & 0xffffffffL; }
Example 12
Source Project: dremio-oss File: TimePrintMillis.java License: Apache License 2.0 | 4 votes |
public TimePrintMillis(LocalDateTime time) { super(time.getHour(), time.getMinute(), time.getSecond()); millisOfSecond = time.get(ChronoField.MILLI_OF_SECOND); }
Example 13
Source Project: jdk1.8-source-analysis File: Timestamp.java License: Apache License 2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 14
Source Project: dragonwell8_jdk File: Timestamp.java License: GNU General Public License v2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 15
Source Project: TencentKona-8 File: Timestamp.java License: GNU General Public License v2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 16
Source Project: hottub File: Timestamp.java License: GNU General Public License v2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 17
Source Project: Java8CN File: Timestamp.java License: Apache License 2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 18
Source Project: jdk8u_jdk File: Timestamp.java License: GNU General Public License v2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 19
Source Project: openjdk-jdk8u-backup File: Timestamp.java License: GNU General Public License v2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }
Example 20
Source Project: openjdk-jdk9 File: Timestamp.java License: GNU General Public License v2.0 | 3 votes |
/** * Obtains an instance of {@code Timestamp} from a {@code LocalDateTime} * object, with the same year, month, day of month, hours, minutes, * seconds and nanos date-time value as the provided {@code LocalDateTime}. * <p> * The provided {@code LocalDateTime} is interpreted as the local * date-time in the local time zone. * * @param dateTime a {@code LocalDateTime} to convert * @return a {@code Timestamp} object * @exception NullPointerException if {@code dateTime} is null. * @since 1.8 */ @SuppressWarnings("deprecation") public static Timestamp valueOf(LocalDateTime dateTime) { return new Timestamp(dateTime.getYear() - 1900, dateTime.getMonthValue() - 1, dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond(), dateTime.getNano()); }