How to generate a Date from just Month and Year in Java?

前端 未结 6 2160
深忆病人
深忆病人 2021-02-12 11:30

I need to generate a new Date object for credit card expiration date, I only have a month and a year, how can I generate a Date based on those two? I need the easiest way possib

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-12 12:12

    The most common sense approach would be to use the Date("YYYY-MM-DD") constructor even though it is deprecated. This is the easiest way to create a date on the fly. Screw whoever decided to deprecate it. Long live Date("YYYY-MM-DD")!!!

提交回复
热议问题