, 2017 , LocalDate java.time, API Java, java.sql.Date. .
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM-dd-uuuu", Locale.US);
LocalDate fromDate = LocalDate.now(ZoneId.of("Asia/Kolkata"));
String tempFromDate = fromDate.format(formatter);
System.out.println(tempFromDate);
-
11-25-2017
LocalDate, java.sql.Date . , , - , , , .
int . int 4284. 4 284 4 284, 004284 . int. . LocalDate ( JDBC- , , PreparedStatement.setObject()).
Getting today's date is a time-sensitive operation because it does not match the date in all time zones of the world. I highly recommend that you make this fact explicit in your code. In my fragment, I used the Asia / Kolkata time zone, please replace the desired time zone. You can use the ZoneId.systemDefault()JVM to set the time zone, but remember that this parameter can be changed under our feet by other parts of your program or by other programs running in the same JVM, so it is fragile.
source
share