本文整理汇总了Java中org.apache.tools.ant.util.DateUtils类的典型用法代码示例。如果您正苦于以下问题:Java DateUtils类的具体用法?Java DateUtils怎么用?Java DateUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DateUtils类属于org.apache.tools.ant.util包,在下文中一共展示了DateUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSeriesData
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
/**
* prepares data for the chart
*
* @return data series
* @throws Exception
*/
private List<Coordinate<String, Number>> getSeriesData() throws Exception {
final List<Coordinate<String, Number>> seriesData = new ArrayList<Coordinate<String, Number>>();
for (final EapEvent event : EapEvent.findByEventType(this.eventType)) {
final Serializable value = event.getValues().get(this.attributeName);
if (value == null) {
throw new Exception("AttributeName " + this.attributeName + " contains null-Values for " + this.eventType);
}
// values should be integer
int intValue = 0;
try {
intValue = Integer.parseInt((String) value);
} catch (final Exception e) {
intValue = (Integer) value;
}
;
seriesData.add(new Coordinate<String, Number>(DateUtils.format(event.getTimestamp(), "'Date.UTC('yyyy, M, d, h, m, s')'"), intValue));
}
return seriesData;
}
示例2: write
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
/**
* @param output The destination, unbuffered
*/
public void write(TestClassResult result, OutputStream output) {
String className = result.getClassName();
long classId = result.getId();
try {
SimpleXmlWriter writer = new SimpleXmlWriter(output, " ");
writer.startElement("testsuite")
.attribute("name", className)
.attribute("tests", String.valueOf(result.getTestsCount()))
.attribute("skipped", String.valueOf(result.getSkippedCount()))
.attribute("failures", String.valueOf(result.getFailuresCount()))
.attribute("errors", "0")
.attribute("timestamp", DateUtils.format(result.getStartTime(), DateUtils.ISO8601_DATETIME_PATTERN))
.attribute("hostname", hostName)
.attribute("time", String.valueOf(result.getDuration() / 1000.0));
writer.startElement("properties");
writer.endElement();
writeTests(writer, result.getResults(), className, classId);
writer.startElement("system-out");
writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdOut);
writer.endElement();
writer.startElement("system-err");
writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdErr);
writer.endElement();
writer.endElement();
} catch (IOException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
}
示例3: run
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
public void run() {
Calendar startDate = new GregorianCalendar();
Calendar endDate = new GregorianCalendar();
endDate.add(Calendar.DAY_OF_MONTH, futureDaysCount);
ObecData obecData = new ObecData();
String sDate = DateUtils.format(startDate.getTime(), "yyyy-MM-dd");
String eDate = DateUtils.format(endDate.getTime(), "yyyy-MM-dd");
String fileName = obecData.generateOBEC(sDate, eDate, properties);
// send generated file to EDT service
UploadData uploadData = toUpload(fileName);
sendUploadData(uploadData);
}
示例4: write
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
public void write(TestClassResult result, OutputStream output) {
String className = result.getClassName();
long classId = result.getId();
try {
SimpleXmlWriter writer = new SimpleXmlWriter(output, " ");
writer.startElement("testsuite")
.attribute("name", className)
.attribute("tests", String.valueOf(result.getTestsCount()))
.attribute("skipped", String.valueOf(result.getSkippedCount()))
.attribute("failures", String.valueOf(result.getFailuresCount()))
.attribute("errors", "0")
.attribute("timestamp", DateUtils.format(result.getStartTime(), DateUtils.ISO8601_DATETIME_PATTERN))
.attribute("hostname", hostName)
.attribute("time", String.valueOf(result.getDuration() / 1000.0));
writer.startElement("properties");
writer.endElement();
writeTests(writer, result.getResults(), className, classId);
writer.startElement("system-out");
writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdOut);
writer.endElement();
writer.startElement("system-err");
writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdErr);
writer.endElement();
writer.endElement();
} catch (IOException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
}
示例5: startTestSuite
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
/**
* The whole testsuite started.
* @param suite the testsuite.
*/
public void startTestSuite(final JUnitTest suite) {
doc = getDocumentBuilder().newDocument();
rootElement = doc.createElement(TESTSUITE);
String n = suite.getName();
// if (n != null && !tag.isEmpty())
// n = n + "-" + tag;
rootElement.setAttribute(ATTR_NAME, n == null ? UNKNOWN : n);
//add the timestamp
final String timestamp = DateUtils.format(new Date(),
DateUtils.ISO8601_DATETIME_PATTERN);
rootElement.setAttribute(TIMESTAMP, timestamp);
//and the hostname.
rootElement.setAttribute(HOSTNAME, getHostname());
// Output properties
final Element propsElement = doc.createElement(PROPERTIES);
rootElement.appendChild(propsElement);
final Properties props = suite.getProperties();
if (props != null) {
final Enumeration e = props.propertyNames();
while (e.hasMoreElements()) {
final String name = (String) e.nextElement();
final Element propElement = doc.createElement(PROPERTY);
propElement.setAttribute(ATTR_NAME, name);
propElement.setAttribute(ATTR_VALUE, props.getProperty(name));
propsElement.appendChild(propElement);
}
}
}
示例6: checkAttributesAndElements
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
/** Check the attributes and elements */
private void checkAttributesAndElements() {
if (baseDir == null && resources.isEmpty() && groupfilesets.isEmpty()
&& "zip".equals(archiveType)) {
throw new BuildException(
"basedir attribute must be set, or at least one resource collection must be given!");
}
if (zipFile == null) {
throw new BuildException("You must specify the %s file to create!",
archiveType);
}
if (fixedModTime != null) {
try {
modTimeMillis = DateUtils.parseLenientDateTime(fixedModTime).getTime();
} catch (ParseException pe) {
throw new BuildException("Failed to parse date string %s.", fixedModTime);
}
if (roundUp) {
modTimeMillis += ROUNDUP_MILLIS;
}
}
if (zipFile.exists() && !zipFile.isFile()) {
throw new BuildException("%s is not a file.", zipFile);
}
if (zipFile.exists() && !zipFile.canWrite()) {
throw new BuildException("%s is read-only.", zipFile);
}
}
示例7: startTestSuite
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
/**
* The whole testsuite started.
* @param suite the testsuite.
*/
@Override
public void startTestSuite(final JUnitTest suite) {
doc = getDocumentBuilder().newDocument();
rootElement = doc.createElement(TESTSUITE);
final String n = suite.getName();
rootElement.setAttribute(ATTR_NAME, n == null ? UNKNOWN : n);
//add the timestamp
final String timestamp = DateUtils.format(new Date(),
DateUtils.ISO8601_DATETIME_PATTERN);
rootElement.setAttribute(TIMESTAMP, timestamp);
//and the hostname.
rootElement.setAttribute(HOSTNAME, getHostname());
// Output properties
final Element propsElement = doc.createElement(PROPERTIES);
rootElement.appendChild(propsElement);
final Properties props = suite.getProperties();
if (props != null) {
for (String name : props.stringPropertyNames()) {
final Element propElement = doc.createElement(PROPERTY);
propElement.setAttribute(ATTR_NAME, name);
propElement.setAttribute(ATTR_VALUE, props.getProperty(name));
propsElement.appendChild(propElement);
}
}
}
示例8: targetFinished
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
/**
* Fired when a target finishes building, this adds the time taken
* and any error stacktrace to the appropriate target element in the log.
*
* @param event An event with any relevant extra information.
* Will not be <code>null</code>.
*/
public void targetFinished(BuildEvent event) {
Target target = event.getTarget();
TimedElement targetElement = (TimedElement) targets.get(target);
if (targetElement != null) {
long totalTime
= System.currentTimeMillis() - targetElement.startTime;
targetElement.element.setAttribute(TIME_ATTR,
DateUtils.formatElapsedTime(totalTime));
TimedElement parentElement = null;
Stack<TimedElement> threadStack = getStack();
if (!threadStack.empty()) {
TimedElement poppedStack = (TimedElement) threadStack.pop();
if (poppedStack != targetElement) {
throw new RuntimeException("Mismatch - popped element = "
+ poppedStack.element + " finished target element = "
+ targetElement.element);
}
if (!threadStack.empty()) {
parentElement = (TimedElement) threadStack.peek();
}
}
if (parentElement == null) {
buildElement.element.appendChild(targetElement.element);
} else {
parentElement.element.appendChild(targetElement.element);
}
}
}
示例9: taskFinished
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
/**
* Fired when a task finishes building, this adds the time taken
* and any error stacktrace to the appropriate task element in the log.
*
* @param event An event with any relevant extra information.
* Will not be <code>null</code>.
*/
public void taskFinished(BuildEvent event) {
Task task = event.getTask();
TimedElement taskElement = (TimedElement) tasks.get(task);
if (taskElement != null) {
long totalTime = System.currentTimeMillis() - taskElement.startTime;
taskElement.element.setAttribute(TIME_ATTR,
DateUtils.formatElapsedTime(totalTime));
Target target = task.getOwningTarget();
TimedElement targetElement = null;
if (target != null) {
targetElement = (TimedElement) targets.get(target);
}
if (targetElement == null) {
buildElement.element.appendChild(taskElement.element);
} else {
targetElement.element.appendChild(taskElement.element);
}
Stack<TimedElement> threadStack = getStack();
if (!threadStack.empty()) {
TimedElement poppedStack = (TimedElement) threadStack.pop();
if (poppedStack != taskElement) {
throw new RuntimeException("Mismatch - popped element = "
+ poppedStack.element + " finished task element = "
+ taskElement.element);
}
}
}
}
示例10: setNotePermissions
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
public ActionForward setNotePermissions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
CaseManagementNoteDAO noteDao = (CaseManagementNoteDAO) SpringUtils.getBean("caseManagementNoteDAO");
ProgramDao programDao = (ProgramDao) SpringUtils.getBean("programDao");
SecroleDao secroleDao = (SecroleDao) SpringUtils.getBean("secroleDao");
String noteId = request.getParameter("noteId");
String newProgramNo = request.getParameter("program");
String newRoleId = request.getParameter("role");
HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("noteId", noteId);
LoggedInInfo loggedInInfo=LoggedInInfo.getLoggedInInfoFromSession(request);
String providerNo=loggedInInfo.getLoggedInProviderNo();
Provider provider = loggedInInfo.getLoggedInProvider();
if (canNoteBeModified(providerNo, noteId)) {
CaseManagementNote note = noteDao.getNote(Long.parseLong(noteId));
// Are this note's permissions being changed after all?
if (note.getReporter_caisi_role() != null && note.getReporter_caisi_role().equalsIgnoreCase(newRoleId)
&& note.getProgram_no() != null && note.getProgram_no().equalsIgnoreCase(newProgramNo)) {
hashMap.put("success", "NO_CHANGE");
} else if (providerHasAccess(providerNo, newProgramNo, newRoleId, note.getDemographic_no())) {
// Check if this provider has access to the requested program & role pair
Program p = programDao.getProgram(Integer.parseInt(newProgramNo));
Secrole r = secroleDao.getRole(Integer.parseInt(newRoleId));
note.setProgram_no(newProgramNo);
note.setReporter_caisi_role(newRoleId);
Date newDate = new Date();
note.setUpdate_date(newDate);
String newNote = note.getNote();
newNote += "\n[" + DateUtils.format(newDate, "yyyy-MM-dd") + " Program/role changed to: " + p.getName() + " (" + r.getName() + ") by " + provider.getLastName() + ", " + provider.getFirstName() + "]";
note.setNote(newNote);
Object id = noteDao.saveAndReturn(note);
hashMap.put("success", "SAVED");
hashMap.put("newProgramNo", newProgramNo);
hashMap.put("newRoleId", newRoleId);
hashMap.put("newProgramName", p.getName());
hashMap.put("newRoleName", r.getName());
hashMap.put("noteContent", newNote);
hashMap.put("newNoteId", id);
} else {
// The provider making this modification won't be able to see the note if this change is made
hashMap.put("error", "MAKES_INVISIBLE");
}
} else {
// The provider doesn't have permission to see this note, so they can't modify it
hashMap.put("error", "PERMISSION_DENIED");
}
JSONObject json = JSONObject.fromObject(hashMap);
response.getOutputStream().write(json.toString().getBytes());
return null;
}
示例11: getPatientList
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
@GET
@Path("/patientList")
@Produces("application/json")
public AbstractSearchResponse<AdmissionTo1> getPatientList(@QueryParam("programNo")String programNo, @QueryParam("day") String day, @QueryParam("startIndex") Integer startIndex, @QueryParam("numToReturn") Integer numToReturn) throws Exception {
AbstractSearchResponse<AdmissionTo1> response = new AbstractSearchResponse<AdmissionTo1>();
if(day == null) {
day = DateFormatUtils.format(Calendar.getInstance(), DateUtils.ISO8601_DATE_PATTERN);
}
Date d = new SimpleDateFormat(DateUtils.ISO8601_DATE_PATTERN).parse(day);
if(programNo == null) {
//get default
ProgramProvider current = null;
ProgramProvider pp = programManager.getCurrentProgramInDomain(getLoggedInInfo(),getLoggedInInfo().getLoggedInProviderNo());
if(pp != null) {
current = pp;
} else {
List<ProgramProvider> ppList = programManager.getProgramDomain(getLoggedInInfo(),getLoggedInInfo().getLoggedInProviderNo());
if(ppList.size()>0) {
current = ppList.get(0);
}
}
if(current != null) {
programNo = String.valueOf(current.getProgramId());
}
}
if(programNo == null) {
throw new Exception("Can't get a program for this provider to use as default");
}
List<AdmissionTo1> transfers = new AdmissionConverter().includeDemographic(true).getAllAsTransferObjects(getLoggedInInfo(),admissionManager.findAdmissionsByProgramAndDate(getLoggedInInfo(), Integer.parseInt(programNo),d,startIndex,numToReturn));
response.setContent(transfers);
response.setTotal(admissionManager.findAdmissionsByProgramAndDateAsCount(getLoggedInInfo(), Integer.parseInt(programNo),d));
return response;
}
示例12: getAppointmentsForDay
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
@GET
@Path("/{providerNo}/day/{date}")
@Produces("application/json")
/**
* Will substitute "me" to your logged in provider no, and "today" to doday's date.
* eg /schedule/me/day/today
*
* @param providerNo
* @param date
* @return
*/
public PatientListApptBean getAppointmentsForDay(@PathParam("providerNo") String providerNo, @PathParam("date") String date) {
SimpleDateFormat timeFormatter = new SimpleDateFormat("hh:mm aa");
LoggedInInfo loggedInInfo = getLoggedInInfo();
PatientListApptBean response = new PatientListApptBean();
try {
Date dateObj = null;
if ("today".equals(date)) {
dateObj = new Date();
} else {
dateObj = DateUtils.parseIso8601Date(date);
}
if ("".equals(providerNo)) {
providerNo = loggedInInfo.getLoggedInProviderNo();
}
List<Appointment> appts = scheduleManager.getDayAppointments(loggedInInfo, providerNo, dateObj);
for (Appointment appt : appts) {
PatientListApptItemBean item = new PatientListApptItemBean();
item.setDemographicNo(appt.getDemographicNo());
if(appt.getDemographicNo() == 0){
item.setName(appt.getName());
}else{
item.setName(demographicManager.getDemographicFormattedName(loggedInInfo, appt.getDemographicNo()));
}
item.setStartTime(timeFormatter.format(appt.getStartTime()));
item.setReason(appt.getReason());
item.setStatus(appt.getStatus());
item.setAppointmentNo(appt.getId());
item.setDate(appt.getStartTimeAsFullDate());
response.getPatients().add(item);
}
} catch (ParseException e) {
throw new RuntimeException("Invalid Date sent, use yyyy-MM-dd format");
}
return response;
}
示例13: getCoordinate
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
private Coordinate<String, Number> getCoordinate(final EapEvent event, final EapEventType eventType) {
return new Coordinate<String, Number>(DateUtils.format(event.getTimestamp(), "'Date.UTC('yyyy, M, d, h, m, s')'"), this.mappingTypeToInt.get(eventType));
}
示例14: getPrimaryFormat
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
@Override
public DateFormat getPrimaryFormat() {
return DateUtils.EN_US_DATE_FORMAT_MIN.get();
}
示例15: getFallbackFormat
import org.apache.tools.ant.util.DateUtils; //导入依赖的package包/类
@Override
public DateFormat getFallbackFormat() {
return DateUtils.EN_US_DATE_FORMAT_SEC.get();
}