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

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

本文整理了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

var calendar = new Calendar({
  format: 'US',
  hideOnClick: true
});

calendar.insertTo(document.body);

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

var calendar = new Calendar();

calendar instanceof Calendar; // true
calendar instanceof Element; // true

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

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

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

// 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;
}

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

function init() {
 var cal = document.getElementById("calendar"),
   today = new Date;

 new Calendar(cal, today);
}

document.addEventListener("DOMContentLoaded", init);

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

public void onServiceConnected(ComponentName className, IBinder service) {

  mBoundService = ((ScheduleService.ServiceBinder) service).getService();
  Calendar c = new Calendar();
  mBoundService.setAlarm(c);
}

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

public static Calendar getInstance(TimeZone zone)
{
  Calendar cal= new Calendar();
  //	cal.setTimeZone(zone);   //TODO: compilador
  return cal;
}

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

<script type="text/javascript" src="calendar.js"></script>
<script type="text/javascript">
  window.onload = function() {
    var cal = new Calendar();
    cal.drawCalendar();
  }
  ...
</script>

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

new Calendar({
   value: new Date(),
   isDisabledDate: lang.hitch(this, function(d){
     return true;
   })
 }, "mycal");

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

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);    
}

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

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);

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

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);

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

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.
}

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

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
}

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

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());

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

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;

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

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);

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

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

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

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);

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

@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();
}

相关文章