var calendar = new Calendar({ format: 'US', hideOnClick: true }); calendar.insertTo(document.body);
var calendar = new Calendar(); calendar instanceof Calendar; // true calendar instanceof Element; // true
var calendar = new Calendar(); document.body.appendChild(calendar._);
// This method is now more testable. Note this is only safe for non-DST zones public static Calendar getCurrentTimeOnly() { Calendar cal = new Calendar(); // DateTimeUtils is part of JodaTime, and is a class allowing you to pause time! cal.setTimeInMillis(DateTimeUtils.currentTimeMillis() % (24 * 60 * 60 * 1000)); return cal; }
function init() { var cal = document.getElementById("calendar"), today = new Date; new Calendar(cal, today); } document.addEventListener("DOMContentLoaded", init);
public void onServiceConnected(ComponentName className, IBinder service) { mBoundService = ((ScheduleService.ServiceBinder) service).getService(); Calendar c = new Calendar(); mBoundService.setAlarm(c); }
public static Calendar getInstance(TimeZone zone) { Calendar cal= new Calendar(); // cal.setTimeZone(zone); //TODO: compilador return cal; }
<script type="text/javascript" src="calendar.js"></script> <script type="text/javascript"> window.onload = function() { var cal = new Calendar(); cal.drawCalendar(); } ... </script>
new Calendar({ value: new Date(), isDisabledDate: lang.hitch(this, function(d){ return true; }) }, "mycal");
Date first = "2011-01-01"; Date last = "2012-01-01"; Calendar cal = new Calendar(first); List<Date> dates = ...; while (first.before(last)) { cal.addDays(1); dates.add(cal); }
XmlDateTime xmlDateTime = XmlDateTime.Factory.newInstance(); Calendar xmlCalendar = new XmlCalendar(); xmlCalendar.set(Calendar.YEAR, 2014); xmlCalendar.set(Calendar.MONTH, 2); xmlCalendar.set(Calendar.DATE, 22); xmlDateTime.setCalendarValue(xmlCalendar);
String strFormat="yyyy/MM/dd"; DateFormat myDateFormat = new SimpleDateFormat(strFormat); Date myDate = new Date(); Calendar calender=new Calender(); myDate = myDateFormat.parse("2007/05/12"); myGDate.setTime(myDate);
public String testSeason(int year, int month, int day) { //month is 0 based! int FIRST_DAY_OF_SPRING = 31 + 28 + 21; // might need leap year detection to be completely accurate. int FRIRST_DAY_OF_SUMMER = FRST_DAY_OF_SPRING + 10 + 31 + 30 +31; // define FALL and WINTER similarly. Calendar testDate = new Calendar(); testDate.set(year,month,day); if (testDate.get(Calendar.DAY_OF_YEAR) < FIRST_DAY_OF_SPRING) return "Winter"; if (testDate.get(Calendar.DAY_OF_YEAR) < FIRST_DAY_OF_SUMMER) return "Spring"; // continue for rest of seasons. }
public Date subtractYear() { final Calendar c = new Calendar(); c.set(year, month, day); // set your class's "current" date c.add(Calendar.YEAR, -1); // remove 1 year return c.getTime(); // get the Date object back from the Calendar }
Calendar cal=new Calendar(); SimpleDateFormat frmDate=SimpleDateFormat("dd-MM-yyyy"); String s=frmDate.format(cal.getTime()); SimpleDateFormat frmTime=SimpleDateFormat("HH:MM:SS"); String t=frmTime.formate(cal.getTime());
Calendar endCalendar = new Calendar(); // Set end to 31th Dec 2013 10:15:30 am local time endCalendar.set(2013, 11, 31, 10, 15, 30); long localEndTimeInMillis = endCalendar.getTimeInMillis(); long localCurrentTimeInMillis = Calendar.getInstance().getTimeInMillis(); // Convert to UTC. // Easy way to compensate if the current and end times are in different DST times utcEndTimeInMillis = getUTCTimeInMillis(localEndTimeInMillis); utcCurrentTimeInMillis = getUTCTimeInMillis(localCurrentTimeInMillis); long difference = utcEndTimeInMillis - utcCurrentTimeInMillis;
Calendar cal1 = new Calendar(); cal1.setTime(date1); Calendar cal2 = new Calendar(); cal2.setTime(date2); boolean equal = true; equal &= cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH); equal &= cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH); equal &= cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR);
public void put(File file) { // upload code FTPFile ftpFile = getJustUploadedFile(file); ftpFile.setTimestamp(new Calendar()); // Now! }
Window window = new Window(); Calendar calendar = new Calendar("Calendar"); calendar.setWidth("100%"); window.setWidth("700px"); window.setHeight("450px"); window.setContent(calendar); window.addWindowModeChangeListener(event -> Page .getCurrent() .getJavaScript() .execute("setTimeout(function() { vaadin.forceLayout(); }, 150);")); Button button = new Button("Click me", event -> UI.getCurrent().addWindow(window)); setContent(button);
@GET @Path("calendar") @Produces("text/calendar") public Response generateCalendar() { Calendar calendar = new Calendar(); // Generate your calendar here ResponseBuilder builder = Response.ok(); builder.header("content-disposition", "attachment;filename=calendar.ics"); builder.entity(calendar.toString()); return builder.build(); }