Example usage for java.time LocalDateTime getSecond

List of usage examples for java.time LocalDateTime getSecond

Introduction

In this page you can find the example usage for java.time LocalDateTime getSecond.

Prototype

public int getSecond() 

Source Link

Document

Gets the second-of-minute field.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01);

    System.out.println(a.getSecond());
}

From source file:Main.java

public static void main(String[] argv) {
    LocalDate today = LocalDate.now();
    System.out.println(String.format("Year : %s Month : %s day : %s", today.getYear(), today.getMonthValue(),
            today.getDayOfMonth()));//w w  w. j  a va  2 s  .com

    LocalDateTime time = LocalDateTime.now();
    System.out.println(
            String.format("Hour : %s Mins : %s Sec : %s", time.getHour(), time.getMinute(), time.getSecond()));

}

From source file:io.hawkcd.agent.utilities.ReportAppender.java

private static String getTimeStamp() {
    // e.g. [10:51:50:564]:
    LocalDateTime now = LocalDateTime.now();
    String format = String.format("[%02d:%02d:%02d]:", now.getHour(), now.getMinute(), now.getSecond());
    return format;
}

From source file:net.atomique.ksar.graph.Graph.java

public int parse_line(LocalDateTime ldt, String s) {

    Second now = new Second(ldt.getSecond(), ldt.getMinute(), ldt.getHour(), ldt.getDayOfMonth(),
            ldt.getMonthValue(), ldt.getYear());

    parse_line(now, s);/*from  w w w .  j  a v a 2s. c  o  m*/
    return 0;
}

From source file:net.atomique.ksar.graph.Graph.java

private Second convertLocalDateTimeToSecond(LocalDateTime ldt) {

    int day = ldt.getDayOfMonth();
    int month = ldt.getMonthValue();
    int year = ldt.getYear();
    int hour = ldt.getHour();
    int minute = ldt.getMinute();
    int second = ldt.getSecond();

    return new Second(second, minute, hour, day, month, year);
}

From source file:msi.gama.util.GamaDate.java

public IList<?> listValue(final IScope scope, final IType<?> ct) {
    final LocalDateTime ld = LocalDateTime.from(internal);
    return GamaListFactory.create(scope, ct, ld.getYear(), ld.getMonthValue(), ld.getDayOfWeek().getValue(),
            ld.getHour(), ld.getMinute(), ld.getSecond());
}

From source file:com.objy.se.ClassAccessor.java

public Object getCorrectValue(String strValue, LogicalType logicalType) {
    Object retValue = null;//  w w w . ja v  a2  s .  c o m
    switch (logicalType) {
    case INTEGER: {
        long attrValue = 0;
        try {
            if (!strValue.equals("")) {
                attrValue = Long.parseLong(strValue);
            }
        } catch (NumberFormatException nfEx) {
            //        System.out.println("... entry: " + entry.getValue() + " for raw: " + entry.getKey());
            nfEx.printStackTrace();
            throw nfEx;
        }
        retValue = Long.valueOf(attrValue);
    }
        break;
    case REAL: {
        double attrValue = 0;
        try {
            if (!strValue.equals("")) {
                attrValue = Double.parseDouble(strValue);
            }
        } catch (NumberFormatException nfEx) {
            //        System.out.println("... entry: " + entry.getValue() + " for raw: " + entry.getKey());
            nfEx.printStackTrace();
            throw nfEx;
        }
        retValue = Double.valueOf(attrValue);
    }
        break;
    case STRING:
        retValue = strValue;
        break;
    case BOOLEAN: {
        if (strValue.equalsIgnoreCase("TRUE") || strValue.equals("1")) {
            retValue = Boolean.valueOf(true);
        } else if (strValue.equalsIgnoreCase("FALSE") || strValue.equals("0")) {
            retValue = Boolean.valueOf(false);
        } else {
            LOG.error("Expected Boolean value but got: {}", strValue);
            throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema"
                    + "... or check records for invalid values");
        }
    }
        break;

    case CHARACTER: {
        if (strValue.length() == 1) {
            retValue = Character.valueOf(strValue.charAt(0));
        } else { /* not a char value... report that */
            LOG.error("Expected Character value but got: {}", strValue);
            throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema"
                    + "... or check records for invalid values");
        }
    }
        break;
    case DATE: {
        try {
            LocalDate ldate = LocalDate.parse(strValue, dateFormatter);
            //            System.out.println("... ... year: " + ldate.getYear() + " - month:" + ldate.getMonthValue());
            retValue = new com.objy.db.Date(ldate.getYear(), ldate.getMonthValue(), ldate.getDayOfMonth());
        } catch (DateTimeParseException ex) {
            LOG.error(ex.toString());
            throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema"
                    + "... or check records for invalid values");
        }
    }
        break;
    case DATE_TIME: {
        try {
            //            System.out.println(".... formatter: " + mapper.getDateTimeFormat());
            LocalDateTime ldt = LocalDateTime.parse(strValue, dateTimeFormatter);
            //            System.out.println("... ... year: " + ldt.getYear() + 
            //                    " - month:" + ldt.getMonthValue() + " - day: " +
            //                    ldt.getDayOfMonth() + " - hour: " + ldt.getHour() +
            //                    " - min: " + ldt.getMinute() + " - sec: " + 
            //                    ldt.getSecond() + " - nsec: " + ldt.getNano() );
            //retValue = new com.objy.db.DateTime(date.getTime(), TimeKind.LOCAL);
            retValue = new com.objy.db.DateTime(ldt.getYear(), ldt.getMonthValue(), ldt.getDayOfMonth(),
                    ldt.getHour(), ldt.getMinute(), ldt.getSecond(), ldt.getNano());
        } catch (DateTimeParseException ex) {
            LOG.error(ex.toString());
            throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema"
                    + "... or check records for invalid values");
        }
    }
        break;
    case TIME: {
        try {
            //            System.out.println(".... formatter: " + mapper.getTimeFormat());
            LocalDateTime ltime = LocalDateTime.parse(strValue, dateFormatter);
            //            System.out.println("... ... hour: " + ltime.getHour() +
            //                    " - min: " + ltime.getMinute() + " - sec: " + 
            //                    ltime.getSecond() + " - nsec: " + ltime.getNano() );
            //retValue = new com.objy.db.DateTime(date.getTime(), TimeKind.LOCAL);
            retValue = new com.objy.db.Time(ltime.getHour(), ltime.getMinute(), ltime.getSecond(),
                    ltime.getNano());
        } catch (DateTimeParseException ex) {
            LOG.error(ex.toString());
            throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema"
                    + "... or check records for invalid values");
        }
    }
    default: {
        throw new UnsupportedOperationException("LogicalType: " + logicalType + " is not supported!!!");
    }
    }
    return retValue;
}

From source file:org.apache.tez.dag.history.logging.proto.DagManifesFileScanner.java

private boolean loadMore() throws IOException {
    LocalDateTime now = manifestLogger.getNow();
    LocalDate today = now.toLocalDate();
    String todayDir = manifestLogger.getDirForDate(today);
    loadNewFiles(todayDir);//from   w  w  w  .ja v  a  2  s.  co m
    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;
}

From source file:org.codice.ddf.admin.insecure.defaults.service.DefaultUsersDeletionScheduler.java

private String cronCalculator(Instant firstInstall) {
    Instant threeDayTimestamp = firstInstall.plus(Duration.ofDays(3).minus(Duration.ofMinutes(30)));
    LocalDateTime localDateTime = LocalDateTime.ofInstant(threeDayTimestamp, ZoneId.systemDefault());

    return String.format("%d+%d+%d+%d+%d+?+%d", localDateTime.getSecond(), localDateTime.getMinute(),
            localDateTime.getHour(), localDateTime.getDayOfMonth(), localDateTime.getMonthValue(),
            localDateTime.getYear());/*  w w w.java2 s  . c  om*/
}