Create, Use Object Of NewAPI
Create new Object
All the core classes in the new API are constructed by fluent factory methods. When constructing a value by its constituent fields, the factory is called of; when converting from another type, the factory is called from. There are also parse methods that take strings as parameters. See 
 
LocalDateTime timePoint = LocalDateTime.now(); // The current date and time
LocalDate.of(2012, Month.DECEMBER, 12); // from values
LocalDate.ofEpochDay(150); // middle of 1970 LocalTime.of(17, 18);
LocalTime.parse("10:15:30"); // From a String
// LocalTime java.time.LocalTime.from(TemporalAccessor temporal)
LocalDateTime timePoint2 = LocalDateTime.from(Month.DECEMBER);
System.out.println(timePoint2.toString());
Use Object
You can also alter the object values in order to perform calculations. 
Because all core classes are immutable in the new API, these methods are called with and return new objects, rather than using setters (see bellow). There are also methods for calculations based on the different fields. 
 // Set the value, returning a new object
LocalDateTime thePast = timePoint.withDayOfMonth(
    10).withYear(2010);
/* You can use direct manipulation methods, 
    or pass a value and field pair */
LocalDateTime yetAnother = thePast.plusWeeks(
    3).plus(3, ChronoUnit.WEEKS);
 
Reference :
https://www.oracle.com/technical-resources/articles/java/jf14-date-time.html
0 comments :
About Me
- Peter
 - Tân An, Long An, Vietnam
 - Hello everyone, I love programming, I love making friends with people all over the world.
 
Contact
Popular Posts
- 
Preface Trong java có 3 kiểu so sánh đặc trưng như sau: + Sử dụng toán tử == : return Boolean Primitive thì so sánh giá trị thực, Reference ...
 - 
1 Copy Object in java Use = for immutable class ex: Integer , String or Wrapper classes Object Use Contructor has paramater copy, ObjectA...
 - 
The cookie contains three part: username: to identify logged-in expirationTime: to expire the cookie; default 2 week password and pridefine...
 - 
Preface Khái niệm Oauth và ApIs Scope and consent (phạm vi và sự đồng ý) Oauth Actor Oauth Tokens Front Back Channel Giả Xác thực Với Oa...
 - 
1) The order of the antMatchers() Note that the order of the antMatchers() elements is significant – the more specific rules need to come ...
 - 
Knowledge of collection in java Interface Iterator interface Collection interface List Interface Queue Interface Deque Interface Se...
 - 
Persistence Context has two implemnet is JPA EntityManage and Hiberbate Session Example use Session of hiberate has exist github you can vi...
 - 
For immutableuse equallist we simple use list.equal list it return true if content same. (compare index) //case true List<Integer> l...
 - 
1) CRUD có thể sử dung find Compositekey hoặc findBy compositeket + column in composite 2) CRUD findBy column And column 3 Not LazyLoa...
 - 
1 check Null and Undefined And primative datatype if(object){ // object is not null, undefined, 0, '', false. but it can empty({})...
 
Post a Comment