本文整理汇总了Python中java.util.Calendar类的典型用法代码示例。如果您正苦于以下问题:Python Calendar类的具体用法?Python Calendar怎么用?Python Calendar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Calendar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
def init(self):
self.getContext().addPropertyChangeListener(self) #ThrottleFrame change
self.getContext().getCurrentThrottleFrame().getAddressPanel().addAddressListener(self) # change of throttle in Current frame
self.addressPanel = self.getContext().getCurrentThrottleFrame().getAddressPanel()
self.throttle = self.addressPanel.getThrottle() # the throttle
self.roster = self.addressPanel.getRosterEntry() # roster entry if any
self.speedAction = SpeedAction() #Speed increase thread
self.speedAction.setThrottle( self.throttle )
self.speedTimer = Timer(valueSpeedTimerRepeat, self.speedAction ) # Very important to use swing Timer object (see Swing and multithreading doc)
self.speedTimer.setRepeats(True)
self.label = JButton(ImageIcon(self.getFolder() + "/USBControl.png","USBThrottle")) #label
self.label.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
self.add(self.label)
self.model = jmri.jmrix.jinput.TreeModel.instance() # USB
self.desiredController = None
self.ctrlMenuItem = []
self.USBDriver = None
self.driver = None
mi = JCheckBoxMenuItem ("None")
self.getPopUpMenu().add( mi )
mi.addItemListener( ControllerItemListener(None, self) )
self.ctrlMenuItem.append(mi)
for ctrl in self.model.controllers():
mi = JCheckBoxMenuItem (ctrl.getName())
self.getPopUpMenu().add( mi )
mi.addItemListener( ControllerItemListener(ctrl, self) )
self.ctrlMenuItem.append(mi)
if ( len(self.ctrlMenuItem) == 0 ):
print "No matching USB device found"
else:
self.ctrlMenuItem[0].setSelected(True) # by default connect to the first one
self.model.addPropertyChangeListener(self)
self.lastTimeStopButton = Calendar.getInstance().getTimeInMillis()
self.lastTimeCruiseButton = Calendar.getInstance().getTimeInMillis()
示例2: setupjob
def setupjob(job, args):
"""
Set up a job to run on telemetry date ranges using data from HBase
Telemetry jobs expect two arguments, startdate and enddate, both in yyyymmdd format.
"""
import java.text.SimpleDateFormat as SimpleDateFormat
import java.util.Calendar as Calendar
import com.mozilla.hadoop.hbase.mapreduce.MultiScanTableMapReduceUtil as MSTMRU
import com.mozilla.util.Pair
if len(args) != 2:
raise Exception("Usage: <startdate-YYYYMMDD> <enddate-YYYYMMDD>")
sdf = SimpleDateFormat(dateformat)
startdate = Calendar.getInstance()
startdate.setTime(sdf.parse(args[0]))
enddate = Calendar.getInstance()
enddate.setTime(sdf.parse(args[1]))
columns = [com.mozilla.util.Pair('data', 'json')]
scans = MSTMRU.generateBytePrefixScans(startdate, enddate, dateformat,
columns, 500, False)
MSTMRU.initMultiScanTableMapperJob(
'telemetry',
scans,
None, None, None, job)
# inform HadoopDriver about the columns we expect to receive
job.getConfiguration().set("org.mozilla.jydoop.hbasecolumns", "data:json");
示例3: to_java_calendar
def to_java_calendar(value):
if isinstance(value, Calendar):
return value
if isinstance(value, datetime.datetime):
c = Calendar.getInstance()
c.set(Calendar.YEAR, value.year)
c.set(Calendar.MONTH, value.month - 1)
c.set(Calendar.DAY_OF_MONTH, value.day)
c.set(Calendar.HOUR_OF_DAY, value.hour)
c.set(Calendar.MINUTE, value.minute)
c.set(Calendar.SECOND, value.second)
c.set(Calendar.MILLISECOND, value.microsecond / 1000)
return c
if isinstance(value, Date):
c = Calendar.getInstance()
c.time = value
return c
if isinstance(value, DateTime):
return value.toGregorianCalendar()
if isinstance(value, DateTimeType):
return value.calendar
raise Exception("Invalid conversion: " + str(type(value)))
示例4: onJava
def onJava(self, e):
self.clockLabel.setText('running')
self.started = Calendar.getInstance().getTimeInMillis();
#print self.textfield1.getText()
#time.sleep(5)
iters = toInt(self.textfield1.getText())
java_smoother(iters)
elapsed = Calendar.getInstance().getTimeInMillis() - self.started;
self.clockLabel.setText( 'Java Elapsed: %.2f seconds' % ( float( elapsed ) / 1000.0 ) )
示例5: __setitem__
def __setitem__(self, key, value):
if key == 'vtecstr':
self.atr.setVtecstr(value)
elif key == 'etn':
self.atr.setEtn(str(value))
elif key == 'sig':
self.atr.setSig(value)
elif key == 'phen':
self.atr.setPhen(value)
elif key == 'segText':
self.atr.setSegText(value)
elif key == 'overviewText':
self.atr.setOverviewText(value)
elif key == 'phensig':
self.atr.setPhensig(value)
elif key == 'act':
self.atr.setAct(value)
elif key =='seg':
self.atr.setSeg(value)
elif key == 'startTime':
start = Calendar.getInstance()
start.setTimeInMillis(long(value * 1000))
self.atr.setStartTime(start)
elif key == 'endTime':
end = Calendar.getInstance()
end.setTimeInMillis(long(value * 1000))
self.atr.setEndTime(end)
elif key == 'purgeTime':
purge = Calendar.getInstance()
purge.setTimeInMillis(long(value * 1000))
self.atr.setPurgeTime(purge)
elif key == 'issueTime':
issue = Calendar.getInstance()
issue.setTimeInMillis(long(value * 1000))
self.atr.setIssueTime(issue)
elif key == 'ufn':
self.atr.setUfn(value)
elif key == 'officeid':
self.atr.setOfficeid(value)
elif key == 'state':
self.state = value
elif key == 'xxxid':
self.atr.setXxxid(value)
elif key == 'pil':
self.atr.setPil(value)
self.pil = value
elif key == 'productClass':
self.atr.setProductClass(value)
elif key == 'id':
self.id = value
elif key == 'rawMessage':
self.atr.setRawmessage(value)
else:
raise KeyError
示例6: __activate__
def __activate__(self, context):
self.auth = context["page"].authentication
self.errorMsg = ""
self.request = context["request"]
self.response = context["response"]
self.fromDtTxt = self.request.getParameter("from")
self.toDtTxt = self.request.getParameter("to")
self.reportName = self.request.getParameter("reportName")
self.dateFormatter = SimpleDateFormat("d/M/yyyy")
self.systemConfig = context["systemConfig"]
if (self.fromDtTxt is None or self.toDtTxt is None):
curCal = Calendar.getInstance()
self.fromDtTxt = "1/1/%s" % curCal.get(Calendar.YEAR)
self.toDtTxt = "%s/%s/%s" % (curCal.get(Calendar.DAY_OF_MONTH), curCal.get(Calendar.MONTH)+1,curCal.get(Calendar.YEAR))
if (self.reportName is None):
self.reportName = "Dashboard Report"
if (self.auth.is_logged_in()):
if (self.auth.is_admin()==True):
self.action = self.request.getParameter("action")
if self.action == "export":
self.exportDashboard(context)
else:
self.buildDashboard(context)
else:
self.errorMsg = "Requires Admin / Librarian / Reviewer access."
else:
self.errorMsg = "Please login."
示例7: setupjob
def setupjob(job, args):
"""
Set up a job to run on a date range of directories.
Jobs expect two arguments, startdate and enddate, both in yyyy-MM-dd format.
"""
import java.text.SimpleDateFormat as SimpleDateFormat
import java.util.Date as Date
import java.util.Calendar as Calendar
import com.mozilla.util.DateUtil as DateUtil
import com.mozilla.util.DateIterator as DateIterator
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat as FileInputFormat
import org.apache.hadoop.mapreduce.lib.input.SequenceFileAsTextInputFormat as MyInputFormat
if len(args) != 3:
raise Exception("Usage: <testpilot_study> <startdate-YYYY-MM-DD> <enddate-YYYY-MM-DD>")
# use to collect up each date in the given range
class MyDateIterator(DateIterator):
def __init__(self):
self._list = []
def get(self):
return self._list
def see(self, aTime):
self._list.append(aTime)
sdf = SimpleDateFormat(dateformat)
study = args[0]
startdate = Calendar.getInstance()
startdate.setTime(sdf.parse(args[1]))
enddate = Calendar.getInstance()
enddate.setTime(sdf.parse(args[2]))
dates = MyDateIterator()
DateUtil.iterateByDay(startdate.getTimeInMillis(), enddate.getTimeInMillis(), dates)
paths = []
for d in dates.get():
paths.append(pathformat % (study, sdf.format(Date(d))))
job.setInputFormatClass(MyInputFormat)
FileInputFormat.setInputPaths(job, ",".join(paths));
job.getConfiguration().set("org.mozilla.jydoop.mappertype", "TEXT")
示例8: lastDay
def lastDay(year,month) :
C = Calendar.getInstance()
C.set(Calendar.YEAR,year)
C.set(Calendar.MONTH,month-1)
C.set(Calendar.DATE,1)
C.add(Calendar.MONTH,1)
C.add(Calendar.DATE,-1)
return C.get(Calendar.DATE)
示例9: tostation
def tostation(self, varname, x, y, z, t):
if isinstance(t, datetime):
cal = Calendar.getInstance()
cal.set(t.year, t.month - 1, t.day, t.hour, t.minute, t.second)
t = cal.getTime()
if z is None:
return self.dataset.toStation(varname, x, y, t)
else:
return self.dataset.toStation(varname, x, y, z, t)
示例10: onTalk
def onTalk (self,npc,player) :
htmltext = "<html><body>目前沒有執行任務,或條件不符。</body></html>"
st = player.getQuestState(qn)
if not st : return htmltext
npcId = npc.getNpcId()
cond = st.getInt("cond")
if npcId == DAICHIR :
if cond == 0 :
reset = st.get("reset")
remain = 0
if reset and reset.isdigit() :
remain = long(reset) - System.currentTimeMillis()
if remain <= 0 :
if player.getLevel() >= 80 :
htmltext = "30537-01.htm"
else :
htmltext = "30537-00.htm"
st.exitQuest(True)
else :
htmltext = "30537-06.htm"
elif cond == 1 :
if st.getQuestItemsCount(DISCHARGED_BEAD) >= 1 :
htmltext = "30537-04a.htm"
else :
htmltext = "30537-04.htm"
elif cond == 2 :
htmltext = "30537-05.htm"
st.giveItems(ADENA,255380)
st.takeItems(DISCHARGED_BEAD,5)
st.setState(State.COMPLETED)
st.unset("cond")
st.unset("altars_state")
st.exitQuest(False)
st.playSound("ItemSound.quest_finish")
reset = Calendar.getInstance()
reset.set(Calendar.MINUTE, RESET_MIN)
# if time is >= RESET_HOUR - roll to the next day
if reset.get(Calendar.HOUR_OF_DAY) >= RESET_HOUR :
reset.add(Calendar.DATE, 1)
reset.set(Calendar.HOUR_OF_DAY, RESET_HOUR)
st.set("reset",str(reset.getTimeInMillis()))
elif cond == 1 and npcId in ALTARS.keys() :
idx = ALTARS[npcId]
state = st.getInt("altars_state")
if (state & idx) == 0 :
st.set("altars_state",str(state | idx))
st.takeItems(REPLENISHED_BEAD,1)
st.giveItems(DISCHARGED_BEAD,1)
st.playSound("ItemSound.quest_itemget")
if st.getQuestItemsCount(DISCHARGED_BEAD) == 5 :
st.set("cond","2")
st.playSound("ItemSound.quest_middle")
htmltext = "recharge.htm"
else :
htmltext = "findother.htm"
return htmltext
示例11: next
def next( self, last, tz = TimeZone.getDefault() ):
cal = Calendar.getInstance( tz, Locale.US )
limit = cal.clone()
limit.add( Calendar.YEAR, 1 )
cal.setTime( last )
cal.add( Calendar.MINUTE, self.wait )
n = self.findNext( cal, limit )
if n == None:
return None
return n.getTime()
示例12: __init__
def __init__(self):
dataDir = Settings.dataDir + 'ProgrammingEmail/CustomizeEmailHeaders/'
# Create a instance of MailMessage class
message = MailMessage()
# Set subject of the message
message.setSubject("New message created by Aspose.Email for Java")
# Set Html body
message.setHtmlBody("<b>This line is in bold.</b> <br/> <br/>" +
"<font color=blue>This line is in blue color</font>")
# Set sender information
message.setFrom(MailAddress("[email protected]", "Sender Name", False))
# Add TO recipients
message.getTo().add(MailAddress("[email protected]", "Recipient 1", False))
# Message subject
message.setSubject("Customizing Email Headers")
# Specify Date
timeZone=TimeZone()
calendar=Calendar()
calendar = calendar.getInstance(timeZone.getTimeZone("GMT"))
date = calendar.getTime()
message.setDate(date)
# Specify XMailer
message.setXMailer("Aspose.Email")
# Specify Secret Header
message.getHeaders().add("secret-header", "mystery")
# Save message to disc
messageFormat=MessageFormat()
message.save(dataDir + "MsgHeaders.msg", messageFormat.getMsg())
# Display Status
print "Customized message headers Successfully."
示例13: init
def init(self):
self.getContext().addPropertyChangeListener(self) #ThrottleFrame change
self.addressPanel=self.getContext().getCurrentThrottleFrame().getAddressPanel();
self.addressPanel.addAddressListener(self) # change of throttle in Current frame
self.throttle = self.getContext().getCurrentThrottleFrame().getAddressPanel().getThrottle() # the throttle
self.speedAction = SpeedAction() #Speed increase thread
self.speedAction.setThrottle( self.throttle )
self.speedTimer = Timer(valueSpeedTimerRepeat, self.speedAction ) # Very important to use swing Timer object (see Swing and multithreading doc)
self.speedTimer.setRepeats(True)
self.label = JButton(ImageIcon(self.getFolder() + "/WiimoteThrottle.png","WiiMote")) #label
self.label.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
self.add(self.label)
self.lastTimeButton1 = Calendar.getInstance().getTimeInMillis()
self.lastTimeButton2 = Calendar.getInstance().getTimeInMillis()
self.lastTimeEStop = Calendar.getInstance().getTimeInMillis()
self.wiiDevice = None
self.sync = thread.allocate_lock() # A lock protecting bellow self.evt
self.evt = None
java.lang.System.setProperty("bluecove.jsr82.psm_minimum_off", "true"); # Required for Bluecove + WiiRemoteJ
WiiRemoteJ.findRemotes(self, 1) # Search for 1 Wiimote, and call back
示例14: gettime
def gettime(self, idx):
date = self.dataset.getDataInfo().getTimes().get(idx)
cal = Calendar.getInstance()
cal.setTime(date)
year = cal.get(Calendar.YEAR)
month = cal.get(Calendar.MONTH) + 1
day = cal.get(Calendar.DAY_OF_MONTH)
hour = cal.get(Calendar.HOUR_OF_DAY)
minute = cal.get(Calendar.MINUTE)
second = cal.get(Calendar.SECOND)
dt = datetime(year, month, day, hour, minute, second)
return dt
示例15: updateText
def updateText(self,textField,startTime):
count=1
while(count < 10000):
#print "start Time" + str(self.getTimeElapsed(startTime))
print "start Time: " + str(int(startTime))
#print "end Time" + str(time.time()-startTime)
elapsed = Calendar.getInstance().getTimeInMillis() - startTime
#print "elapsed Time" + self.getTimeElapsed(elapsed)
timer =Timer(1000,self.printTime,())
timer.start()
textField.setText( 'Elapsed: %.2f seconds' % ( float( elapsed ) / 1000.0 ) );
count =count+1