Skip to content

Commit

Permalink
README updated with latest code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shounaks committed Feb 15, 2024
1 parent 8e9f961 commit 7554263
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions jr-extension-javatime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Added in Jackson 2.17.
To be able to use supported annotations, you need to register extension like so:
```java
private static final JSON JACKSON = JSON.builder()
.register(new JacksonLocalDateTimeExtension())
.register(new JacksonJavaTimeExtension())
.build();
```
after which you can use normal read and write operations as usual:
Expand All @@ -19,22 +19,37 @@ after which you can use normal read and write operations as usual:

import java.time.LocalDateTime;

class Application {
public class Application {

public static void main(String[] args) {
// Create the class that we need to
final LocalDateTime now = LocalDateTime.now();
MyClass myObject = new MyClass(now, 'Some Other Values....');
String myObjectJsonString = JACKSON.asString(myObject);
MyClass myObjectFromJson = JACKSON.beanFrom(MyClass, myObjectJsonString);
assert myObjectFromJson.time == now;
assert myObjectFromJson.getTime().equals(now);
}

}

// ...

public class MyClass {
private LocalDateTime time;
private String otherItems;

public MyClass(LocalDateTime datetime, String others) {
//...
}

public LocalDateTime getTime() {
return time;
}
// other getters & setters
}
```

### Extension List
- LocalDateTime (`JacksonLocalDateTimeExtension`)
### Date Classes currently supported by `JacksonJavaTimeExtension`
- LocalDateTime

### Plans for Future
- Other Java 8 DateTime classes

0 comments on commit 7554263

Please sign in to comment.