Skip to content

Commit e92b19a

Browse files
committed
Fix date formatting bug in Controller
1 parent 1e790d3 commit e92b19a

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

Advanced/auction-cordapp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ available in the `Active Auction` section.
111111

112112
5. Place one more bid by switching to PartyC.
113113

114-
6. What for the auction to end.
114+
6. Wait for the auction to end.
115115

116116
7. Once the auction is ended its ready to be settled. Settlement can be initiated by the
117117
highest bidder. Considering PartyC is the highest bidder, switch to PartyC.

Advanced/auction-cordapp/client/src/main/java/net/corda/samples/auction/client/Controller.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
import org.springframework.beans.factory.annotation.Qualifier;
1515
import org.springframework.web.bind.annotation.*;
1616

17+
import java.text.SimpleDateFormat;
1718
import java.time.LocalDateTime;
18-
import java.time.format.DateTimeFormatter;
19+
import java.time.ZoneId;
1920
import java.util.List;
2021
import java.util.UUID;
2122
import java.util.concurrent.ExecutionException;
@@ -71,11 +72,12 @@ public APIResponse<Void> createAsset(@RequestBody Forms.AssetForm assetForm){
7172
@PostMapping("create")
7273
public APIResponse<Void> createAuction(@RequestBody Forms.CreateAuctionForm auctionForm){
7374
try {
75+
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss a");
76+
LocalDateTime formattedDeadline = LocalDateTime.ofInstant(dateFormatter.parse(auctionForm.getDeadline()).toInstant(), ZoneId.systemDefault());
7477
activeParty.startFlowDynamic(CreateAuctionFlow.CreateAuctionInitiator.class,
7578
Amount.parseCurrency(auctionForm.getBasePrice() + " USD"),
7679
UUID.fromString(auctionForm.getAssetId()),
77-
LocalDateTime.parse(auctionForm.getDeadline(),
78-
DateTimeFormatter.ofPattern("dd-MM-yyyy hh:mm:ss a"))).getReturnValue().get();
80+
formattedDeadline).getReturnValue().get();
7981
return APIResponse.success();
8082
}catch (ExecutionException e){
8183
if(e.getCause() != null && e.getCause().getClass().equals(TransactionVerificationException.ContractRejection.class)){

0 commit comments

Comments
 (0)