java.util.Calendar.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(272)

本文整理了Java中java.util.Calendar.<init>()方法的一些代码示例,展示了Calendar.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Calendar.<init>()方法的具体详情如下:
包路径:java.util.Calendar
类名称:Calendar
方法名:<init>

Calendar.<init>介绍

[英]Constructs a Calendar instance using the default TimeZone and Locale.
[中]使用默认时区和区域设置构造日历实例。

代码示例

代码示例来源:origin: stackoverflow.com

  1. var calendar = new Calendar({
  2. format: 'US',
  3. hideOnClick: true
  4. });
  5. calendar.insertTo(document.body);

代码示例来源:origin: stackoverflow.com

  1. var calendar = new Calendar();
  2. calendar instanceof Calendar; // true
  3. calendar instanceof Element; // true

代码示例来源:origin: stackoverflow.com

  1. var calendar = new Calendar();
  2. document.body.appendChild(calendar._);

代码示例来源:origin: stackoverflow.com

  1. // This method is now more testable. Note this is only safe for non-DST zones
  2. public static Calendar getCurrentTimeOnly() {
  3. Calendar cal = new Calendar();
  4. // DateTimeUtils is part of JodaTime, and is a class allowing you to pause time!
  5. cal.setTimeInMillis(DateTimeUtils.currentTimeMillis() % (24 * 60 * 60 * 1000));
  6. return cal;
  7. }

代码示例来源:origin: stackoverflow.com

  1. function init() {
  2. var cal = document.getElementById("calendar"),
  3. today = new Date;
  4. new Calendar(cal, today);
  5. }
  6. document.addEventListener("DOMContentLoaded", init);

代码示例来源:origin: stackoverflow.com

  1. public void onServiceConnected(ComponentName className, IBinder service) {
  2. mBoundService = ((ScheduleService.ServiceBinder) service).getService();
  3. Calendar c = new Calendar();
  4. mBoundService.setAlarm(c);
  5. }

代码示例来源:origin: dragome/dragome-sdk

  1. public static Calendar getInstance(TimeZone zone)
  2. {
  3. Calendar cal= new Calendar();
  4. // cal.setTimeZone(zone); //TODO: compilador
  5. return cal;
  6. }

代码示例来源:origin: stackoverflow.com

  1. <script type="text/javascript" src="calendar.js"></script>
  2. <script type="text/javascript">
  3. window.onload = function() {
  4. var cal = new Calendar();
  5. cal.drawCalendar();
  6. }
  7. ...
  8. </script>

代码示例来源:origin: stackoverflow.com

  1. new Calendar({
  2. value: new Date(),
  3. isDisabledDate: lang.hitch(this, function(d){
  4. return true;
  5. })
  6. }, "mycal");

代码示例来源:origin: stackoverflow.com

  1. Date first = "2011-01-01";
  2. Date last = "2012-01-01";
  3. Calendar cal = new Calendar(first);
  4. List<Date> dates = ...;
  5. while (first.before(last)) {
  6. cal.addDays(1);
  7. dates.add(cal);
  8. }

代码示例来源:origin: stackoverflow.com

  1. XmlDateTime xmlDateTime = XmlDateTime.Factory.newInstance();
  2. Calendar xmlCalendar = new XmlCalendar();
  3. xmlCalendar.set(Calendar.YEAR, 2014);
  4. xmlCalendar.set(Calendar.MONTH, 2);
  5. xmlCalendar.set(Calendar.DATE, 22);
  6. xmlDateTime.setCalendarValue(xmlCalendar);

代码示例来源:origin: stackoverflow.com

  1. String strFormat="yyyy/MM/dd";
  2. DateFormat myDateFormat = new SimpleDateFormat(strFormat);
  3. Date myDate = new Date();
  4. Calendar calender=new Calender();
  5. myDate = myDateFormat.parse("2007/05/12");
  6. myGDate.setTime(myDate);

代码示例来源:origin: stackoverflow.com

  1. public String testSeason(int year, int month, int day) {
  2. //month is 0 based!
  3. int FIRST_DAY_OF_SPRING = 31 + 28 + 21; // might need leap year detection to be completely accurate.
  4. int FRIRST_DAY_OF_SUMMER = FRST_DAY_OF_SPRING + 10 + 31 + 30 +31;
  5. // define FALL and WINTER similarly.
  6. Calendar testDate = new Calendar();
  7. testDate.set(year,month,day);
  8. if (testDate.get(Calendar.DAY_OF_YEAR) < FIRST_DAY_OF_SPRING) return "Winter";
  9. if (testDate.get(Calendar.DAY_OF_YEAR) < FIRST_DAY_OF_SUMMER) return "Spring";
  10. // continue for rest of seasons.
  11. }

代码示例来源:origin: stackoverflow.com

  1. public Date subtractYear() {
  2. final Calendar c = new Calendar();
  3. c.set(year, month, day); // set your class's "current" date
  4. c.add(Calendar.YEAR, -1); // remove 1 year
  5. return c.getTime(); // get the Date object back from the Calendar
  6. }

代码示例来源:origin: stackoverflow.com

  1. Calendar cal=new Calendar();
  2. SimpleDateFormat frmDate=SimpleDateFormat("dd-MM-yyyy");
  3. String s=frmDate.format(cal.getTime());
  4. SimpleDateFormat frmTime=SimpleDateFormat("HH:MM:SS");
  5. String t=frmTime.formate(cal.getTime());

代码示例来源:origin: stackoverflow.com

  1. Calendar endCalendar = new Calendar();
  2. // Set end to 31th Dec 2013 10:15:30 am local time
  3. endCalendar.set(2013, 11, 31, 10, 15, 30);
  4. long localEndTimeInMillis = endCalendar.getTimeInMillis();
  5. long localCurrentTimeInMillis = Calendar.getInstance().getTimeInMillis();
  6. // Convert to UTC.
  7. // Easy way to compensate if the current and end times are in different DST times
  8. utcEndTimeInMillis = getUTCTimeInMillis(localEndTimeInMillis);
  9. utcCurrentTimeInMillis = getUTCTimeInMillis(localCurrentTimeInMillis);
  10. long difference = utcEndTimeInMillis - utcCurrentTimeInMillis;

代码示例来源:origin: stackoverflow.com

  1. Calendar cal1 = new Calendar();
  2. cal1.setTime(date1);
  3. Calendar cal2 = new Calendar();
  4. cal2.setTime(date2);
  5. boolean equal = true;
  6. equal &= cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH);
  7. equal &= cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH);
  8. equal &= cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR);

代码示例来源:origin: stackoverflow.com

  1. public void put(File file) {
  2. // upload code
  3. FTPFile ftpFile = getJustUploadedFile(file);
  4. ftpFile.setTimestamp(new Calendar()); // Now!
  5. }

代码示例来源:origin: stackoverflow.com

  1. Window window = new Window();
  2. Calendar calendar = new Calendar("Calendar");
  3. calendar.setWidth("100%");
  4. window.setWidth("700px");
  5. window.setHeight("450px");
  6. window.setContent(calendar);
  7. window.addWindowModeChangeListener(event -> Page
  8. .getCurrent()
  9. .getJavaScript()
  10. .execute("setTimeout(function() { vaadin.forceLayout(); }, 150);"));
  11. Button button = new Button("Click me", event -> UI.getCurrent().addWindow(window));
  12. setContent(button);

代码示例来源:origin: stackoverflow.com

  1. @GET
  2. @Path("calendar")
  3. @Produces("text/calendar")
  4. public Response generateCalendar() {
  5. Calendar calendar = new Calendar();
  6. // Generate your calendar here
  7. ResponseBuilder builder = Response.ok();
  8. builder.header("content-disposition", "attachment;filename=calendar.ics");
  9. builder.entity(calendar.toString());
  10. return builder.build();
  11. }

相关文章