java - How to compare objects of LocalDate and Calendar class? -
i trying compare dates 2 object having different types. there way convert calendar object localdater or vice-versa?
thank :)
public class abc{ public static void main(string args[]){ calendar c1= calendar.getinstance(); localdate c2= localdate.now(); system.out.println(c1.compareto(c2)); } }
you need compare dates, let's that.
using this answer reference:
calendar calendar = calendar.getinstance(); localdate localdate = localdate.now(); localdate calendaraslocaldate = calendar.toinstant() .atzone(calendar.gettimezone().tozoneid()) .tolocaldate(); return calendaraslocaldate.compareto(localdate)
Comments
Post a Comment