code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public final Cursor<T> select (Connection conn, String condition)
{
String query = "select " + listOfFields + " from " + name +
" " + condition;
return new Cursor<T>(this, conn, query);
} | java |
public synchronized void insert (Connection conn, T obj)
throws SQLException
{
StringBuilder sql = new StringBuilder(
"insert into " + name + " (" + listOfFields + ") values (?");
for (int i = 1; i < nColumns; i++) {
sql.append(",?");
}
sql.append(")")... | java |
public synchronized void insert (Connection conn, T[] objects)
throws SQLException
{
StringBuilder sql = new StringBuilder(
"insert into " + name + " (" + listOfFields + ") values (?");
for (int i = 1; i < nColumns; i++) {
sql.append(",?");
}
sql.appen... | java |
public synchronized int delete (Connection conn, T obj)
throws SQLException
{
if (primaryKeys == null) {
throw new IllegalStateException(
"No primary key for table " + name + ".");
}
int nDeleted = 0;
StringBuilder sql = new StringBuilder(
... | java |
public synchronized int delete (Connection conn, T[] objects)
throws SQLException
{
if (primaryKeys == null) {
throw new IllegalStateException(
"No primary key for table " + name + ".");
}
int nDeleted = 0;
StringBuilder sql = new StringBuilder(
... | java |
public static boolean restrictQueryExecution(String sql) {
String[] restrictions = { "delete", "truncate", "update", "drop", "alter" };
if (sql != null) {
sql = sql.toLowerCase();
for (String restriction : restrictions) {
if (sql.startsWith(restriction)) {
return true;
}
String regex = "\\s+"... | java |
public static boolean isValidProcedureCall(String sql, Dialect dialect) {
if (sql == null) {
return false;
}
if (dialect instanceof OracleDialect) {
return sql.split("\\?").length == 2;
} else {
return true;
}
} | java |
public static Expression compile(String exp) {
if (Miscellaneous.isEmpty(exp) || exp.equals(".")) {
exp = "$";
}
Queue<String> queue = new LinkedList<String>();
List<String> tokens = parseTokens(exp);
boolean isInBracket = false;
int numInBracket = 0;
... | java |
public static void addDragSource (
DragSource source, JComponent comp, boolean autoremove)
{
singleton.addSource(source, comp, autoremove);
} | java |
public static void addDropTarget (
DropTarget target, JComponent comp, boolean autoremove)
{
singleton.addTarget(target, comp, autoremove);
} | java |
protected void addSource (
DragSource source, JComponent comp, boolean autoremove)
{
_draggers.put(comp, source);
comp.addMouseListener(_sourceListener);
comp.addMouseMotionListener(_sourceListener);
if (autoremove) {
comp.addAncestorListener(_remover);
}
... | java |
protected void removeSource (JComponent comp)
{
if (_sourceComp == comp) {
// reset cursors
clearComponentCursor();
_topComp.setCursor(_topCursor);
reset();
}
_draggers.remove(comp);
comp.removeMouseListener(_sourceListener);
co... | java |
protected void addTarget (
DropTarget target, JComponent comp, boolean autoremove)
{
_droppers.put(comp, target);
addTargetListeners(comp);
if (autoremove) {
comp.addAncestorListener(_remover);
}
} | java |
protected void addTargetListeners (Component comp)
{
comp.addMouseListener(_targetListener);
comp.addMouseMotionListener(_targetListener);
if (comp instanceof Container) { // hm, always true for JComp..
Container cont = (Container) comp;
cont.addContainerListener(_chi... | java |
protected void removeTargetListeners (Component comp)
{
comp.removeMouseListener(_targetListener);
comp.removeMouseMotionListener(_targetListener);
if (comp instanceof Container) { // again, always true for JComp...
Container cont = (Container) comp;
cont.removeContai... | java |
protected void setComponentCursor (Component comp)
{
Cursor c = comp.getCursor();
if (c != _curCursor) {
assertComponentCursorCleared();
_lastComp = comp;
_oldCursor = comp.isCursorSet() ? c : null;
comp.setCursor(_curCursor);
}
} | java |
protected DropTarget findAppropriateTarget (Component comp)
{
DropTarget target;
while (comp != null) {
// here we sneakily prevent dropping on the source
target = (comp == _sourceComp) ? null : _droppers.get(comp);
if ((target != null) && comp.isEnabled() &&
... | java |
protected void checkAutoscroll (MouseEvent exitEvent)
{
Component comp = exitEvent.getComponent();
Point p = exitEvent.getPoint();
try {
Point scr = comp.getLocationOnScreen();
p.translate(scr.x, scr.y);
} catch (IllegalComponentStateException icse) {
... | java |
protected Rectangle getRectOnScreen (JComponent comp)
{
Rectangle r = comp.getVisibleRect();
Point p = comp.getLocationOnScreen();
r.translate(p.x, p.y);
return r;
} | java |
protected void reset ()
{
_scrollTimer.stop();
_source = null;
_sourceComp = null;
_lastComp = null;
_lastTarget = null;
_data[0] = null;
_cursors[0] = null;
_cursors[1] = null;
_topComp = null;
_topCursor = null;
_curCursor = ... | java |
public static Report loadConvertedReport(InputStream is) {
XStream xstream = XStreamFactory.createXStream();
InputStreamReader reader = null;
try {
reader = new InputStreamReader(is, "UTF-8");
return (Report) xstream.fromXML(reader);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
e.printStack... | java |
public static Report loadConvertedReport(String xml) {
XStream xstream = XStreamFactory.createXStream();
try {
return (Report) xstream.fromXML(xml);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
e.printStackTrace();
return null;
}
} | java |
public static Report loadReport(String xml) throws LoadReportException {
try {
String convertedXml = ConverterChain.applyFromXml(xml);
XStream xstream = XStreamFactory.createXStream();
return (Report) xstream.fromXML(convertedXml);
} catch (ConverterException ex) {
LOG.error(ex.getMessage(), ex);
thr... | java |
public static Report loadReport(InputStream is) throws LoadReportException {
try {
String xml = readAsString(is);
String convertedXml = ConverterChain.applyFromXml(xml);
XStream xstream = XStreamFactory.createXStream();
return (Report) xstream.fromXML(convertedXml);
} catch (Exception ex) {
LOG.error... | java |
public static void saveReport(Report report, OutputStream out) {
XStream xstream = XStreamFactory.createXStream();
xstream.toXML(report, out);
} | java |
public static void saveReport(Report report, String path) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(path);
saveReport(report, fos);
} catch (Exception ex) {
LOG.error(ex.getMessage(), ex);
ex.printStackTrace();
} finally {
if (fos != null) {
try {
fos.close();
}... | java |
public static void saveReport(String xml, String path) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(path);
fos.write(xml.getBytes("UTF-8"));
fos.flush();
} catch (Exception ex) {
LOG.error(ex.getMessage(), ex);
ex.printStackTrace();
} finally {
if (fos != null) {
try {
... | java |
public static String reportToXml(Report report) {
XStream xstream = XStreamFactory.createXStream();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
xstream.toXML(report, bos);
return bos.toString();
} | java |
public static byte isValid(String reportVersion) {
if (isOlderUnsupportedVersion(reportVersion)) {
return REPORT_INVALID_OLDER;
} else if (isNewerUnsupportedVersion(reportVersion)) {
return REPORT_INVALID_NEWER;
} else {
return REPORT_VALID;
}
} | java |
public static boolean isOlderUnsupportedVersion(String version) {
return ((version == null) || "".equals(version) || version.startsWith("0") || version.startsWith("1"));
} | java |
public static boolean isNewerUnsupportedVersion(String version) {
if ((version == null) || "".equals(version)) {
return true;
}
String engineVersion = ReleaseInfoAdapter.getVersionNumber();
String[] ev = engineVersion.split("\\.");
String[] rv = version.split("\\.");
return ((Integer.parseInt(ev[0]) < In... | java |
public static int compareVersions(String v1, String v2) {
String[] v1a = v1.split("\\.");
String[] v2a = v2.split("\\.");
Integer v1M = Integer.parseInt(v1a[0]);
Integer v2M = Integer.parseInt(v2a[0]);
if (v1M < v2M) {
return -1;
} else if (v1M > v2M) {
return 1;
} else {
Integer v1min = Integer.... | java |
public static String getVersion(String reportFile) {
try {
String text = readAsString(reportFile);
return getVersionFromText(text);
} catch (IOException e) {
LOG.error(e.getMessage(), e);
return null;
}
} | java |
public static String getVersion(InputStream is) {
try {
String text = readAsString(is);
return getVersionFromText(text);
} catch (IOException e) {
LOG.error(e.getMessage(), e);
return null;
}
} | java |
public static String readAsString(String reportPath) throws IOException {
StringBuffer fileData = new StringBuffer(1000);
BufferedReader reader = new BufferedReader(new FileReader(reportPath));
char[] buf = new char[1024];
int numRead = 0;
while ((numRead = reader.read(buf)) != -1) {
fileData.append(buf, 0... | java |
public static String readAsString(InputStream is) throws IOException {
try {
// Scanner iterates over tokens in the stream, and in this case
// we separate tokens using "beginning of the input boundary" (\A)
// thus giving us only one token for the entire contents of the
// stream
return new Scanner(is... | java |
public static String getFileName(String filePath) {
if (filePath == null) {
return filePath;
}
int index = filePath.lastIndexOf(File.separator);
if (index == -1) {
return filePath;
}
return filePath.substring(index + 1);
} | java |
public static List<String> getStaticImages(Report report) {
List<String> images = new ArrayList<String>();
ReportLayout layout = report.getLayout();
List<Band> bands = layout.getBands();
for (Band band : bands) {
for (int i = 0, rows = band.getRowCount(); i < rows; i++) {
List<BandElement> list = band.ge... | java |
public static String getSql(Report report) {
String sql;
if (report.getSql() != null) {
sql = report.getSql();
} else {
sql = report.getQuery().toString();
}
return sql;
} | java |
public static List<ExpressionBean> getExpressions(ReportLayout layout) {
List<ExpressionBean> expressions = new LinkedList<ExpressionBean>();
for (Band band : layout.getBands()) {
for (int i = 0, rows = band.getRowCount(); i < rows; i++) {
List<BandElement> list = band.getRow(i);
for (BandElement be : li... | java |
public static List<String> getExpressionsNames(ReportLayout layout) {
List<String> expressions = new LinkedList<String>();
for (Band band : layout.getBands()) {
for (int i = 0, rows = band.getRowCount(); i < rows; i++) {
List<BandElement> list = band.getRow(i);
for (BandElement be : list) {
if (be i... | java |
public static String isValidSqlWithMessage(Connection con, String sql, List<QueryParameter> parameters) {
try {
QueryUtil qu = new QueryUtil(con, DialectUtil.getDialect(con));
Map<String, QueryParameter> params = new HashMap<String, QueryParameter>();
for (QueryParameter qp : parameters) {
params.pu... | java |
public static List<Report> getSubreports(Report report) {
List<Report> subreports = new ArrayList<Report>();
List<Band> bands = report.getLayout().getDocumentBands();
for (Band band : bands) {
for (int i = 0, rows = band.getRowCount(); i < rows; i++) {
List<BandElement> list = band.getRow(i);
for (i... | java |
public static List<Report> getDetailSubreports(ReportLayout reportLayout) {
List<Report> subreports = new ArrayList<Report>();
Band band = reportLayout.getDetailBand();
for (int i = 0, rows = band.getRowCount(); i < rows; i++) {
List<BandElement> list = band.getRow(i);
for (int j = 0, size = list.size(); j... | java |
public static List<Chart> getDetailCharts(ReportLayout reportLayout) {
List<Chart> charts = new ArrayList<Chart>();
Band band = reportLayout.getDetailBand();
for (int i = 0, rows = band.getRowCount(); i < rows; i++) {
List<BandElement> list = band.getRow(i);
for (int j = 0, size = list.size(); j < size; j+... | java |
private static ReportLayout getForReportLayout(Connection con, ReportLayout layout, ParametersBean pBean) throws Exception {
ReportLayout convertedLayout = ObjectCloner.silenceDeepCopy(layout);
List<Band> bands = convertedLayout.getDocumentBands();
for (Band band : bands) {
for (int i = 0, rows = band.getRowC... | java |
public static boolean foundFunctionInGroupHeader(ReportLayout layout, String groupName) {
List<Band> groupHeaderBands = layout.getGroupHeaderBands();
for (Band band : groupHeaderBands) {
if (band.getName().equals(ReportLayout.GROUP_HEADER_BAND_NAME_PREFIX + groupName)) {
return foundFunctionInBand(band);... | java |
public static boolean foundFunctionInAnyGroupHeader(ReportLayout layout) {
List<Band> groupHeaderBands = layout.getGroupHeaderBands();
for (Band band : groupHeaderBands) {
boolean found = foundFunctionInBand(band);
if (found) {
return true;
}
}
return false;
} | java |
public void addFieldParser (String property, FieldParser parser)
{
if (_parsers == null) {
_parsers = new HashMap<String,FieldParser>();
}
_parsers.put(property, parser);
} | java |
public static Field[] getFields (Class<?> clazz)
{
ArrayList<Field> list = new ArrayList<Field>();
getFields(clazz, list);
return list.toArray(new Field[list.size()]);
} | java |
public static boolean compatibleClasses (Class<?>[] lhs, Class<?>[] rhs)
{
if (lhs.length != rhs.length) {
return false;
}
for (int i = 0; i < lhs.length; ++i) {
if (rhs[i] == null || rhs[i].equals(Void.TYPE)) {
if (lhs[i].isPrimitive()) {
... | java |
public static Method getAccessibleMethodFrom (
Class<?> clazz, String methodName, Class<?>[] parameterTypes)
{
// Look for overridden method in the superclass.
Class<?> superclass = clazz.getSuperclass();
Method overriddenMethod = null;
if (superclass != null && classIsAcces... | java |
public static boolean primitiveIsAssignableFrom (Class<?> lhs, Class<?> rhs)
{
if (lhs == null || rhs == null) {
return false;
}
if (!(lhs.isPrimitive() && rhs.isPrimitive())) {
return false;
}
if (lhs.equals(rhs)) {
return true;
}
... | java |
private void createStar() {
Point2D.Float point = start;
p = new GeneralPath(GeneralPath.WIND_NON_ZERO);
p.moveTo(point.x, point.y);
p.lineTo(point.x + 3.0f, point.y - 1.5f); // Line from start to A
point = (Point2D.Float) p.getCurrentPoint();
p.lineTo(point.x ... | java |
Shape atLocation(float x, float y) {
start.setLocation(x, y); // Store new start
p.reset(); // Erase current path
createStar(); // create new path
return p; ... | java |
public static int[] add (int[] list, int startIdx, int value)
{
// make sure we've got a list to work with
if (list == null) {
list = new int[DEFAULT_LIST_SIZE];
}
// search for a spot to insert yon value; assuming we'll insert
// it at the end of the list if we ... | java |
public static int remove (int[] list, int value)
{
// nothing to remove from an empty list
if (list == null) {
return 0;
}
int llength = list.length; // no optimizing bastards
for (int i = 0; i < llength; i++) {
int val = list[i];
if (val ... | java |
public static int removeAt (int[] list, int index)
{
int llength = list.length;
if (llength <= index) {
return 0;
}
int val = list[index];
System.arraycopy(list, index+1, list, index, llength-(index+1));
list[llength-1] = 0;
return val;
} | java |
public static int sum (int[] list)
{
int total = 0, lsize = list.length;
for (int ii = 0; ii < lsize; ii++) {
total += list[ii];
}
return total;
} | java |
protected static int[] accomodate (int[] list, int index)
{
int size = list.length;
// expand size by powers of two until we're big enough
while (size <= index) {
size = Math.max(size * 2, DEFAULT_LIST_SIZE);
}
// create a new list and copy the contents
i... | java |
public static Integer[] box (int[] list)
{
if (list == null) {
return null;
}
Integer[] boxed = new Integer[list.length];
for (int ii = 0; ii < list.length; ii++) {
boxed[ii] = list[ii];
}
return boxed;
} | java |
public static List<Integer> asList (int[] list)
{
if (list == null) {
return null;
}
List<Integer> ilist = new ArrayList<Integer>(list.length);
for (int ii = 0; ii < list.length; ii++) {
ilist.add(list[ii]);
}
return ilist;
} | java |
public static void attachHandler (
String protocol, Class<? extends URLStreamHandler> handlerClass)
{
// set up the factory.
if (_handlers == null) {
_handlers = new HashMap<String,Class<? extends URLStreamHandler>>();
// There are two ways to do this.
/... | java |
public URLStreamHandler createURLStreamHandler (String protocol)
{
Class<? extends URLStreamHandler> handler = _handlers.get(protocol.toLowerCase());
if (handler != null) {
try {
return handler.newInstance();
} catch (Exception e) {
log.warning... | java |
public static <E extends Enum<E> & ByteEnum> E fromByte (Class<E> eclass, byte code)
{
for (E value : eclass.getEnumConstants()) {
if (value.toByte() == code) {
return value;
}
}
throw new IllegalArgumentException(eclass + " has no value with code " + ... | java |
public static <E extends Enum<E> & ByteEnum> int setToInt (Set<E> set)
{
int flags = 0;
for (E value : set) {
flags |= toIntFlag(value);
}
return flags;
} | java |
public static <E extends Enum<E> & ByteEnum> EnumSet<E> intToSet (Class<E> eclass, int flags)
{
EnumSet<E> set = EnumSet.noneOf(eclass);
for (E value : eclass.getEnumConstants()) {
if ((flags & toIntFlag(value)) != 0) {
set.add(value);
}
}
retu... | java |
protected static void initLogger ()
{
// if a custom class was specified as a system property, use that
Factory factory = createConfiguredFactory();
// create and a log4j logger if the log4j configuration system property is set
try {
if (factory == null && System.getProp... | java |
protected Constraints getConstraints (Component child)
{
if (_constraints != null) {
Constraints c = _constraints.get(child);
if (c != null) {
return c;
}
}
return DEFAULT_CONSTRAINTS;
} | java |
protected DimenInfo computeDimens (Container parent, int type) {
int count = parent.getComponentCount();
DimenInfo info = new DimenInfo();
info.dimens = new Dimension[count];
for (int i = 0; i < count; i++) {
Component child = parent.getComponent(i);
if (!child.i... | java |
protected void checkCreate ()
{
if (_creator != null && isShowing()) {
// ideally, we would replace ourselves in our parent, but that
// doesn't seem to work in JTabbedPane
setLayout(new BorderLayout());
add(_creator.createContent(), BorderLayout.CENTER);
... | java |
public void invokeTask (Component parent, String retryMessage)
throws Exception
{
while (true) {
try {
invoke();
return;
} catch (Exception e) {
Object[] options = new Object[] {
"Retry operation", "Abort op... | java |
public void update ()
{
// grab the various system properties
osName = System.getProperty("os.name");
osVersion = System.getProperty("os.version");
osArch = System.getProperty("os.arch");
javaVersion = System.getProperty("java.version");
javaVendor = System.getPropert... | java |
public void add (T element)
{
DependencyNode<T> node = new DependencyNode<T>(element);
_nodes.put(element, node);
_orphans.add(element);
} | java |
public void remove (T element)
{
DependencyNode<T> node = _nodes.remove(element);
_orphans.remove(element);
// Remove ourselves as a child of our parents.
for (DependencyNode<T> parent : node.parents) {
parent.children.remove(node);
}
// Remove ourselves... | java |
public void addDependency (T dependant, T dependee)
{
_orphans.remove(dependant);
DependencyNode<T> dependantNode = _nodes.get(dependant);
if (dependantNode == null) {
throw new IllegalArgumentException("Unknown dependant? " + dependant);
}
DependencyNode<T> depen... | java |
public boolean dependsOn (T elem1, T elem2)
{
DependencyNode<T> node1 = _nodes.get(elem1);
DependencyNode<T> node2 = _nodes.get(elem2);
List<DependencyNode<T>> nodesToCheck = new ArrayList<DependencyNode<T>>();
List<DependencyNode<T>> nodesAlreadyChecked = new ArrayList<DependencyNo... | java |
public ObserverList<T> toObserverList ()
{
ObserverList<T> list = ObserverList.newSafeInOrder();
while (!isEmpty()) {
list.add(removeAvailableElement());
}
return list;
} | java |
public void remove (String name)
{
// we treat the old value as a String, I hope that's ok!
String oldValue = getValue(name, (String) null);
_prefs.remove(name);
_propsup.firePropertyChange(name, oldValue, null);
} | java |
public static String restrictHTML (String src, boolean allowFormatting,
boolean allowImages, boolean allowLinks)
{
// TODO: these regexes should probably be checked to make
// sure that javascript can't live inside a link
ArrayList<String> allow = new ArrayList<String>();
if ... | java |
public static String restrictHTML (String src, String[] regexes)
{
if (StringUtil.isBlank(src)) {
return src;
}
ArrayList<String> list = new ArrayList<String>();
list.add(src);
for (String regexe : regexes) {
Pattern p = Pattern.compile(regexe, Patter... | java |
public void requestFailed (Exception cause)
{
Object[] args = _args != null ? ArrayUtil.append(_args, cause) : new Object[] { cause };
if (_slogger != null) {
_slogger.warning(_errorText, args);
} else if (_jlogger != null) {
_jlogger.log(Level.WARNING, Logger.format(... | java |
public static int compare(Date d1, Date d2) {
Calendar c1 = Calendar.getInstance();
c1.setTime(d1);
Calendar c2 = Calendar.getInstance();
c2.setTime(d2);
if (c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) {
if (c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH)) {
... | java |
public static int getYear(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.YEAR);
} | java |
public static int getMonth(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.MONTH);
} | java |
public static int getDayOfYear(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.DAY_OF_YEAR);
} | java |
public static int getDayOfMonth(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.DAY_OF_MONTH);
} | java |
public static int getDayOfWeek(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.DAY_OF_WEEK);
} | java |
public static int getHour(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.HOUR_OF_DAY);
} | java |
public static int getMinute(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.MINUTE);
} | java |
public static int getSecond(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.SECOND);
} | java |
public static Date floor(Date d) {
Calendar c = Calendar.getInstance();
c.setTime(d);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
} | java |
public static boolean sameDay(Date dateOne, Date dateTwo) {
if ((dateOne == null) || (dateTwo == null)) {
return false;
}
Calendar cal = Calendar.getInstance();
cal.setTime(dateOne);
int year = cal.get(Calendar.YEAR);
int day = cal.get(Calendar.DAY_OF_YEAR);
... | java |
public static boolean sameWeek(Date dateOne, Date dateTwo) {
if ((dateOne == null) || (dateTwo == null)) {
return false;
}
Calendar cal = Calendar.getInstance();
cal.setTime(dateOne);
int year = cal.get(Calendar.YEAR);
int week = cal.get(Calendar.WEEK_OF_YEAR... | java |
public static boolean sameMonth(Date dateOne, Date dateTwo) {
if ((dateOne == null) || (dateTwo == null)) {
return false;
}
Calendar cal = Calendar.getInstance();
cal.setTime(dateOne);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
... | java |
public static boolean sameHour(Date dateOne, Date dateTwo) {
if ((dateOne == null) || (dateTwo == null)) {
return false;
}
Calendar cal = Calendar.getInstance();
cal.setTime(dateOne);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
... | java |
public static int getNumberOfDays(Date first, Date second)
{
Calendar c = Calendar.getInstance();
int result = 0;
int compare = first.compareTo(second);
if (compare > 0) return 0;
if (compare == 0) return 1;
c.setTime(first);
int firstDay = c.... | java |
public static int[] getElapsedTime(Date first, Date second) {
if (first.compareTo(second) == 1 ) {
return null;
}
int difDays = 0;
int difHours = 0;
int difMinutes = 0;
Calendar c = Calendar.getInstance();
c.setTime(first);
int h1 = c.... | java |
public static Date addMinutes(Date d, int minutes) {
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(Calendar.MINUTE, minutes);
return cal.getTime();
} | java |
public static Date setMinutes(Date d, int minutes) {
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.set(Calendar.MINUTE, minutes);
return cal.getTime();
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.