If you are experiencing an issue please mention the full platform your
issue applies to:
IDE: NetBeans/Eclipse/IDEA Netbeand 11
Desktop OS Windows 10 Pro
Simulator Latest
Device Simulator, possibly devices
I have a method that passed date and time integers to Calendar to sed a
Date object.
Curious, I diod not see this before unless it just broke.
int year = 2020;
int month = 3;
int dayinmonth = 20;
int hour = 1700;
int min = 20;
int sec = 0;
java.util.Date dte1 =
getDateObjectFromYYYY_MM_DD_HH_MM_SS(year, month, dayinmonth, hour, min,
sec);
System.out.println("dte1 = [" + dte1 + "]");
Printed = (dte1 = [Sat May 30 08:20:00 EDT 2020])
public java.util.Date getDateObjectFromYYYY_MM_DD_HH_MM_SS(int year,
int month, int day, int hour, int min, int sec) {
Calendar cal = Calendar.getInstance();
try {
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month-1);
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.HOUR, hour);
cal.set(Calendar.MINUTE, min);
cal.set(Calendar.SECOND, sec);
} catch (Exception e) {
e.printStackTrace();
}
return (cal.getTime()); // Returns a java.util.Date object
}
Thoughts?
Regards
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/267dd3df-cffa-4faf-9b85-18afb3430487%40googlegroups.com.