-2

I'm stuck between java.time.temporal.ChronoUnit and java.time.temporal.Temporal until. How do they work??

  • 1
    What are you stuck with? Did you check the documentation? – Arvind Kumar Avinash Aug 08 '20 at 16:23
  • @ArvindKumarAvinash I think you accidentially closed the question as the wrong duplicate. – dan1st Aug 08 '20 at 16:27
  • @dan1st - When I closed it, your answer had not been posted (check the closing time). Interestingly, you were able to post the answer probably because you might have drafted your answer. Generally, I try to avoid closing a question if someone has already answered. My opinion for this question is that it's not only duplicate, but OP also has not put any effort. Even if I vote to open it, it will be closed by someone for lack of focus/effort. What do you say? – Arvind Kumar Avinash Aug 08 '20 at 16:40
  • I wrote my answer on the SE mobile app and it is possible, there if you start writing the answer before the closure. I personally think that this is not a bad question itself as `ChronoUnit` and `TemporalUnit` seem fairly similar, even if I completely agree that there seems not to be much effort put into this question. – dan1st Aug 08 '20 at 16:44
  • Welcome to Stack Overflow. Your title and your question body seem to be asking two very different questions. You probably meant the same question, so could you please explain how the two are related? Also report what your search turned up and what more precisely you are still missing after that or how the results were confusing or not helpful. – Ole V.V. Aug 08 '20 at 19:05
  • As a normal programmer you should usually not use the `Temporal` interface. `ChronoUnit` is the way to go for calculating a difference. – Ole V.V. Aug 08 '20 at 19:10

1 Answers1

2

Look at the javadoc for ChronoUnit and TemporalUntit.

The ChronoUnit enum basically provides some standard TemporalUnits but other developers could implement other TemporalUnits.

For example, you can write the following code:

TemporalUnit u=ChronoUnit.DAYS;

but you can also create new TemporalUnits by extending ChronoUnit.

dan1st
  • 12,568
  • 8
  • 34
  • 67