List of usage examples for java.time LocalDateTime getNano
public int getNano()
From source file:Main.java
public static void main(String[] args) { LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01); System.out.println(a.getNano()); }
From source file:com.objy.se.ClassAccessor.java
public Object getCorrectValue(String strValue, LogicalType logicalType) { Object retValue = null;//from w ww. j a v a2s . 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; }