Date and calendar java -
class employee { private date doj; public employee (date doj) { this.doj=doj; } public date getdoj() { return doj; } } class testemployeesort { public static list<employee> getemployees() { list<employee> col=new arraylist<employee>(); col.add(new employee(new date(1986,21,22)); } }
in above code have used date set date. want know how use calendar function this. know can use getinstance() , set date. don't know how implement it. please me know how set date using calendar function
string months[] = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" }; calendar calendar = calendar.getinstance(); system.out.print("date: "); system.out.print(months[calendar.get(calendar.month)]); system.out.print(" " + calendar.get(calendar.date) + " "); system.out.println(calendar.get(calendar.year)); system.out.print("time: "); system.out.print(calendar.get(calendar.hour) + ":"); system.out.print(calendar.get(calendar.minute) + ":"); system.out.println(calendar.get(calendar.second)); calendar.set(calendar.hour, 10); calendar.set(calendar.minute, 29); calendar.set(calendar.second, 22); system.out.print("updated time: "); system.out.print(calendar.get(calendar.hour) + ":"); system.out.print(calendar.get(calendar.minute) + ":"); system.out.println(calendar.get(calendar.second));
Comments
Post a Comment