-2

Date 2022-02-02 (yyyy-dd-MM) to 02-Feb-2022 in Java

need help in converting Date 2022-02-02 to format 02-Feb-2022

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
R M
  • 69
  • 1
  • 7
  • Where did you put your search engine? Please learn that you are supposed to search before asking a question here and when you post a question, tell us what your search brought up and specify how it fell short of solving your problem. It’s for your own sake since (1) you often find a better answer faster that way (2) it allows us to give preciser and more focused answers. It also tends to prevent or at least reduce the number of downvotes. – Ole V.V. Mar 24 '22 at 14:16

1 Answers1

1
LocalDate.parse("2022-02-02", DateTimeFormatter.ofPattern("yyyy-dd-MM")).format(DateTimeFormatter.ofPattern("dd-MMM-yyyy"));
Ryan
  • 1,762
  • 6
  • 11
  • Depends on his locale. In America, it would be month first. In Europe, day first. – Ryan Mar 23 '22 at 18:28
  • Fair enough. Process is the same though which I think is what he's really after. I'll edit it though, – Ryan Mar 23 '22 at 18:31
  • The order yyyy-dd-MM doesn’t agree with any standard order I have ever seen anywhere in the world. So I may still suspect it’s an error. Most Europeans put day before month but then year last. For example 24/03/22 or 24 mars 2022. – Ole V.V. Mar 24 '22 at 14:14
  • Basically the correct answer. You should specify a locale for the formatter used for formatting to make sure that `Feb` comes in the desired language. – Ole V.V. Mar 24 '22 at 14:24