bugged
stringlengths
6
599k
fixed
stringlengths
6
40.8M
__index_level_0__
int64
0
3.24M
private ColorChooserComponentFactory() { } // ColorChooserComponentFactory()
private ColorChooserComponentFactory() { } // ColorChooserComponentFactory()
7,514
public SwingDialogPeer(SwingToolkit toolkit, Dialog dialog) { super(toolkit, dialog, new SwingDialog(dialog)); jComponent.setTitle(dialog.getTitle()); jComponent.getContentPane().setLayout(null); }
public SwingDialogPeer(SwingToolkit toolkit, Dialog dialog) { super(toolkit, dialog, new SwingDialog(dialog)); jComponent.setTitle(dialog.getTitle()); jComponent.getContentPane().setLayout(null); }
7,515
public AccessibleContext getAccessibleContext(){ /* Create the context if this is the first request */ if (accessibleContext == null) { /* Create the context */ accessibleContext = new AccessibleAWTLabel(); } return accessibleContext;}
public AccessibleContext getAccessibleContext(){ /* Create the context if this is the first request */ if (accessibleContext == null) { /* Create the context */ accessibleContext = new AccessibleAWTLabel(); } return accessibleContext;}
7,517
public AccessibleContext getAccessibleContext(){ /* Create the context if this is the first request */ if (accessibleContext == null) { /* Create the context */ accessibleContext = new AccessibleAWTLabel(); } return accessibleContext;}
public AccessibleContext getAccessibleContext(){ /* Create the context if this is the first request */ if (accessibleContext == null) { /* Create the context */ accessibleContext = new AccessibleAWTLabel(); return accessibleContext;}
7,518
public static FileSystemView getFileSystemView() { if (defaultFileSystemView == null) { if (File.separator.equals("/")) defaultFileSystemView = new UnixFileSystemView(); // FIXME: need to implement additional views // else if (File.Separator.equals("\")) // return new Win32FileSystemView(); // else // return new GenericFileSystemView(); } return defaultFileSystemView; }
public static FileSystemView getFileSystemView() { if (defaultFileSystemView == null) { defaultFileSystemView = new UnixFileSystemView(); // FIXME: need to implement additional views // else if (File.Separator.equals("\")) // return new Win32FileSystemView(); // else // return new GenericFileSystemView(); } return defaultFileSystemView; }
7,519
public static FileSystemView getFileSystemView() { if (defaultFileSystemView == null) { if (File.separator.equals("/")) defaultFileSystemView = new UnixFileSystemView(); // FIXME: need to implement additional views // else if (File.Separator.equals("\")) // return new Win32FileSystemView(); // else // return new GenericFileSystemView(); } return defaultFileSystemView; }
public static FileSystemView getFileSystemView() { if (defaultFileSystemView == null) { if (File.separator.equals("/"))defaultFileSystemView = new UnixFileSystemView(); // FIXME: need to implement additional views // else if (File.Separator.equals("\")) // return new Win32FileSystemView(); // else// return new GenericFileSystemView(); } return defaultFileSystemView; }
7,520
public String getSystemDisplayName(File f) { return null; }
public String getSystemDisplayName(File f) { String name = null; if (f != null) name = f.getName(); return name; }
7,521
protected void fireConfigChanged() { if (listeners != null) { int size = listeners.size(); for (int i = 0; i < size; i++) { SessionConfigListener target = (SessionConfigListener)listeners.elementAt(i); target.onConfigChanged(sce); } } }
protected void fireConfigChanged(SessionConfigEvent sce) { if (listeners != null) { int size = listeners.size(); for (int i = 0; i < size; i++) { SessionConfigListener target = (SessionConfigListener)listeners.elementAt(i); target.onConfigChanged(sce); } } }
7,522
public List getAxisTags() { List tags = new ArrayList(); String tag; String axisId; String tempTag; List axisList = getParentArray().getAxisList(); int counter = axisList.size(); for (int i = 0; i<axisList.size(); i++) { axisId = ((Axis)axisList.get(i)).getAxisId(); tag = "d" + counter--; //the default tag //should it exist, we use whats in the tag hash //otherwise we go with the default as singed above tempTag = (String) tagHash.get(axisId); if (tempTag!=null) tag = tempTag; tags.add(tag); } return tags; }
public List getAxisTags() { List tags = new ArrayList(); String tag; String axisId; String tempTag; List axisList = getParentArray().getAxisList(); int counter = axisList.size(); for (int i = 0; i<axisList.size(); i++) { axisId = ((Axis)axisList.get(i)).getAxisId(); tag = "d" + counter--; //the default tag //should it exist, we use whats in the tag hash //otherwise we go with the default as singed above tempTag = (String) tagHash.get(axisId); if (tempTag!=null) tag = tempTag; tags.add(tag); } return tags; }
7,523
public List getAxisTags() { List tags = new ArrayList(); String tag; String axisId; String tempTag; List axisList = getParentArray().getAxisList(); int counter = axisList.size(); for (int i = 0; i<axisList.size(); i++) { axisId = ((Axis)axisList.get(i)).getAxisId(); tag = "d" + counter--; //the default tag //should it exist, we use whats in the tag hash //otherwise we go with the default as singed above tempTag = (String) tagHash.get(axisId); if (tempTag!=null) tag = tempTag; tags.add(tag); } return tags; }
public List getAxisTags() { List tags = new ArrayList(); String tag; String axisId; String tempTag; List axisList = getParentArray().getAxisList(); int counter = axisList.size(); for (int i = 0; i<axisList.size(); i++) { axisId = ((Axis)axisList.get(i)).getAxisId(); tag = "d" + counter--; //the default tag //should it exist, we use whats in the tag hash //otherwise we go with the default as singed above tempTag = (String) tagHash.get(axisId); if (tempTag!=null) tag = tempTag; tags.add(tag); } return tags; }
7,524
public List getAxisTags() { List tags = new ArrayList(); String tag; String axisId; String tempTag; List axisList = getParentArray().getAxisList(); int counter = axisList.size(); for (int i = 0; i<axisList.size(); i++) { axisId = ((Axis)axisList.get(i)).getAxisId(); tag = "d" + counter--; //the default tag //should it exist, we use whats in the tag hash //otherwise we go with the default as singed above tempTag = (String) tagHash.get(axisId); if (tempTag!=null) tag = tempTag; tags.add(tag); } return tags; }
public List getAxisTags() { List tags = new ArrayList(); String tag; String axisId; String tempTag; List axisList = getParentArray().getAxisList(); int counter = axisList.size(); for (int i = 0; i<axisList.size(); i++) { axisId = ((Axis)axisList.get(i)).getAxisId(); counter--; tag = "d" + counter; //the default tag //should it exist, we use whats in the tag hash //otherwise we go with the default as singed above tempTag = (String) tagHash.get(axisId); if (tempTag!=null) tag = tempTag; tags.add(tag); } return tags; }
7,525
public List getAxisTags() { List tags = new ArrayList(); String tag; String axisId; String tempTag; List axisList = getParentArray().getAxisList(); int counter = axisList.size(); for (int i = 0; i<axisList.size(); i++) { axisId = ((Axis)axisList.get(i)).getAxisId(); tag = "d" + counter--; //the default tag //should it exist, we use whats in the tag hash //otherwise we go with the default as singed above tempTag = (String) tagHash.get(axisId); if (tempTag!=null) tag = tempTag; tags.add(tag); } return tags; }
public List getAxisTags() { List tags = new ArrayList(); String tag; String axisId; String tempTag; List axisList = getParentArray().getAxisList(); int counter = axisList.size(); for (int i = 0; i<axisList.size(); i++) { axisId = ((Axis)axisList.get(i)).getAxisId(); tag = "d" + counter--; //the default tag //should it exist, we use whats in the tag hash //otherwise we go with the default as singed above tempTag = (String) tagHash.get(axisId); if (tempTag!=null) tag = tempTag; tags[i] = tag; } return tags; }
7,526
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent ) { boolean niceOutput = super.sPrettyXDFOutput; String myIndent; if (indent!=null) myIndent = indent; else myIndent = ""; String moreIndent = myIndent + super.sPrettyXDFOutputIndentation; if (niceOutput) writeOut(outputstream, myIndent); //open the read block writeOut(outputstream, "<"+classXDFNodeName); //get attribute info Hashtable xmlInfo = getXMLInfo(); //write out attributes ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); synchronized(attribs) { //sync, prevent the attribs' structure be changed for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } writeOut(outputstream, ">"); if (niceOutput) writeOut(outputstream, Constants.NEW_LINE); //write out the tags info List tags = Collections.synchronizedList(getAxisTags()); List axisList = parentArray.getAxisList(); String axisId; String tag; for (int i = 0; i <axisList.size(); i++) { axisId = ((Axis) axisList.get(i)).getAxisId(); tag = (String)tags.get(i); if (niceOutput) { writeOut(outputstream, moreIndent); } writeOut(outputstream, "<" + TagToAxisNodeName + " axisIdRef=\\" + axisId + "\\" + "tag = \\" + tag + "\\/>"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } } //close the read block if (niceOutput) { writeOut(outputstream,indent); } writeOut(outputstream, "</"+classXDFNodeName+">"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } }
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent ) { boolean niceOutput = super.sPrettyXDFOutput; String myIndent; if (indent!=null) myIndent = indent; else myIndent = ""; String moreIndent = myIndent + super.sPrettyXDFOutputIndentation; if (niceOutput) writeOut(outputstream, myIndent); //open the read block writeOut(outputstream, "<"+classXDFNodeName); //get attribute info Hashtable xmlInfo = getXMLInfo(); //write out attributes ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); synchronized(attribs) { //sync, prevent the attribs' structure be changed int stop = attribs.size(); for (int i = 0; i < stop; i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } writeOut(outputstream, ">"); if (niceOutput) writeOut(outputstream, Constants.NEW_LINE); //write out the tags info List tags = Collections.synchronizedList(getAxisTags()); List axisList = parentArray.getAxisList(); String axisId; String tag; for (int i = 0; i <axisList.size(); i++) { axisId = ((Axis) axisList.get(i)).getAxisId(); tag = (String)tags.get(i); if (niceOutput) { writeOut(outputstream, moreIndent); } writeOut(outputstream, "<" + TagToAxisNodeName + " axisIdRef=\\" + axisId + "\\" + "tag = \\" + tag + "\\/>"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } } //close the read block if (niceOutput) { writeOut(outputstream,indent); } writeOut(outputstream, "</"+classXDFNodeName+">"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } }
7,527
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent ) { boolean niceOutput = super.sPrettyXDFOutput; String myIndent; if (indent!=null) myIndent = indent; else myIndent = ""; String moreIndent = myIndent + super.sPrettyXDFOutputIndentation; if (niceOutput) writeOut(outputstream, myIndent); //open the read block writeOut(outputstream, "<"+classXDFNodeName); //get attribute info Hashtable xmlInfo = getXMLInfo(); //write out attributes ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); synchronized(attribs) { //sync, prevent the attribs' structure be changed for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } writeOut(outputstream, ">"); if (niceOutput) writeOut(outputstream, Constants.NEW_LINE); //write out the tags info List tags = Collections.synchronizedList(getAxisTags()); List axisList = parentArray.getAxisList(); String axisId; String tag; for (int i = 0; i <axisList.size(); i++) { axisId = ((Axis) axisList.get(i)).getAxisId(); tag = (String)tags.get(i); if (niceOutput) { writeOut(outputstream, moreIndent); } writeOut(outputstream, "<" + TagToAxisNodeName + " axisIdRef=\\" + axisId + "\\" + "tag = \\" + tag + "\\/>"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } } //close the read block if (niceOutput) { writeOut(outputstream,indent); } writeOut(outputstream, "</"+classXDFNodeName+">"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } }
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent ) { boolean niceOutput = super.sPrettyXDFOutput; String myIndent; if (indent!=null) myIndent = indent; else myIndent = ""; String moreIndent = myIndent + super.sPrettyXDFOutputIndentation; if (niceOutput) writeOut(outputstream, myIndent); //open the read block writeOut(outputstream, "<"+classXDFNodeName); //get attribute info Hashtable xmlInfo = getXMLInfo(); //write out attributes ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); synchronized(attribs) { //sync, prevent the attribs' structure be changed for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } writeOut(outputstream, ">"); if (niceOutput) writeOut(outputstream, Constants.NEW_LINE); //write out the tags info String[] tags = getAxisTags(); List axisList = parentArray.getAxisList(); String axisId; String tag; for (int i = 0; i <axisList.size(); i++) { axisId = ((Axis) axisList.get(i)).getAxisId(); tag = (String)tags.get(i); if (niceOutput) { writeOut(outputstream, moreIndent); } writeOut(outputstream, "<" + TagToAxisNodeName + " axisIdRef=\\" + axisId + "\\" + "tag = \\" + tag + "\\/>"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } } //close the read block if (niceOutput) { writeOut(outputstream,indent); } writeOut(outputstream, "</"+classXDFNodeName+">"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } }
7,528
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent ) { boolean niceOutput = super.sPrettyXDFOutput; String myIndent; if (indent!=null) myIndent = indent; else myIndent = ""; String moreIndent = myIndent + super.sPrettyXDFOutputIndentation; if (niceOutput) writeOut(outputstream, myIndent); //open the read block writeOut(outputstream, "<"+classXDFNodeName); //get attribute info Hashtable xmlInfo = getXMLInfo(); //write out attributes ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); synchronized(attribs) { //sync, prevent the attribs' structure be changed for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } writeOut(outputstream, ">"); if (niceOutput) writeOut(outputstream, Constants.NEW_LINE); //write out the tags info List tags = Collections.synchronizedList(getAxisTags()); List axisList = parentArray.getAxisList(); String axisId; String tag; for (int i = 0; i <axisList.size(); i++) { axisId = ((Axis) axisList.get(i)).getAxisId(); tag = (String)tags.get(i); if (niceOutput) { writeOut(outputstream, moreIndent); } writeOut(outputstream, "<" + TagToAxisNodeName + " axisIdRef=\\" + axisId + "\\" + "tag = \\" + tag + "\\/>"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } } //close the read block if (niceOutput) { writeOut(outputstream,indent); } writeOut(outputstream, "</"+classXDFNodeName+">"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } }
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent ) { boolean niceOutput = super.sPrettyXDFOutput; String myIndent; if (indent!=null) myIndent = indent; else myIndent = ""; String moreIndent = myIndent + super.sPrettyXDFOutputIndentation; if (niceOutput) writeOut(outputstream, myIndent); //open the read block writeOut(outputstream, "<"+classXDFNodeName); //get attribute info Hashtable xmlInfo = getXMLInfo(); //write out attributes ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); synchronized(attribs) { //sync, prevent the attribs' structure be changed for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } writeOut(outputstream, ">"); if (niceOutput) writeOut(outputstream, Constants.NEW_LINE); //write out the tags info List tags = Collections.synchronizedList(getAxisTags()); List axisList = parentArray.getAxisList(); String axisId; String tag; for (int i = 0; i <axisList.size(); i++) { axisId = ((Axis) axisList.get(i)).getAxisId(); tag = (String)tags.get(i); if (niceOutput) { writeOut(outputstream, moreIndent); } writeOut(outputstream, "<" + TagToAxisNodeName + " axisIdRef=\\" + axisId + "\\" + "tag = \\" + tag + "\\/>"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } } //close the read block if (niceOutput) { writeOut(outputstream,indent); } writeOut(outputstream, "</"+classXDFNodeName+">"); if (niceOutput) { writeOut(outputstream,Constants.NEW_LINE); } }
7,529
public final void saveScreen() throws IOException { ByteArrayOutputStream sc = new ByteArrayOutputStream(); sc.write(4); sc.write(0x12); // 18 sc.write(0); // 18 sc.write(0); // 18 sc.write((byte) screen52.getRows()); // store the current size sc.write((byte) screen52.getColumns()); // "" int cp = screen52.getCurrentPos(); // save off current position sc.write((byte) (cp >> 8 & 0xff)); // "" sc.write((byte) (cp & 0xff)); // "" sc.write((byte) (screen52.homePos >> 8 & 0xff)); // save home pos sc.write((byte) (screen52.homePos & 0xff)); // "" int rows = screen52.getRows(); // store the current size int cols = screen52.getColumns(); // ""// byte[] sa = new byte[rows * cols]; fillRegenerationBuffer(sc,rows,cols);// fillScreenArray(sa, rows, cols);//// sc.write(sa);// sa = null; int sizeFields = screen52.getScreenFields().getSize(); sc.write((byte) (sizeFields >> 8 & 0xff)); // "" sc.write((byte) (sizeFields & 0xff)); // "" if (sizeFields > 0) { int x = 0; int s = screen52.getScreenFields().getSize(); ScreenField sf = null; while (x < s) { sf = screen52.getScreenFields().getField(x); sc.write((byte) sf.getAttr()); // attribute int sp = sf.startPos(); sc.write((byte) (sp >> 8 & 0xff)); // "" sc.write((byte) (sp & 0xff)); // "" if (sf.mdt) sc.write((byte) 1); else sc.write((byte) 0); sc.write((byte) (sf.getLength() >> 8 & 0xff)); // "" sc.write((byte) (sf.getLength() & 0xff)); // "" sc.write((byte) sf.getFFW1() & 0xff); sc.write((byte) sf.getFFW2() & 0xff); sc.write((byte) sf.getFCW1() & 0xff); sc.write((byte) sf.getFCW2() & 0xff); log.debug("Saved "); log.debug(sf.toString()); x++; } sf = null; } // The following two lines of code looks to have caused all sorts of // problems so for now we have commented them out. // screen52.getScreenFields().setCurrentField(null); // set it to null // for GC ? // screen52.clearTable(); try { writeGDS(0, 3, sc.toByteArray()); } catch (IOException ioe) { log.warn(ioe.getMessage()); } sc = null; log.debug("Save Screen end "); }
public final void saveScreen() throws IOException { ByteArrayOutputStream sc = new ByteArrayOutputStream(); sc.write(4); sc.write(0x12); // 18 sc.write(0); // 18 sc.write(0); // 18 sc.write((byte) screen52.getRows()); // store the current size sc.write((byte) screen52.getColumns()); // "" int cp = screen52.getScreenFields().getCurrentFieldPos(); // save off current position sc.write((byte) (cp >> 8 & 0xff)); // "" sc.write((byte) (cp & 0xff)); // "" sc.write((byte) (screen52.homePos >> 8 & 0xff)); // save home pos sc.write((byte) (screen52.homePos & 0xff)); // "" int rows = screen52.getRows(); // store the current size int cols = screen52.getColumns(); // ""// byte[] sa = new byte[rows * cols]; fillRegenerationBuffer(sc,rows,cols);// fillScreenArray(sa, rows, cols);//// sc.write(sa);// sa = null; int sizeFields = screen52.getScreenFields().getSize(); sc.write((byte) (sizeFields >> 8 & 0xff)); // "" sc.write((byte) (sizeFields & 0xff)); // "" if (sizeFields > 0) { int x = 0; int s = screen52.getScreenFields().getSize(); ScreenField sf = null; while (x < s) { sf = screen52.getScreenFields().getField(x); sc.write((byte) sf.getAttr()); // attribute int sp = sf.startPos(); sc.write((byte) (sp >> 8 & 0xff)); // "" sc.write((byte) (sp & 0xff)); // "" if (sf.mdt) sc.write((byte) 1); else sc.write((byte) 0); sc.write((byte) (sf.getLength() >> 8 & 0xff)); // "" sc.write((byte) (sf.getLength() & 0xff)); // "" sc.write((byte) sf.getFFW1() & 0xff); sc.write((byte) sf.getFFW2() & 0xff); sc.write((byte) sf.getFCW1() & 0xff); sc.write((byte) sf.getFCW2() & 0xff); log.debug("Saved "); log.debug(sf.toString()); x++; } sf = null; } // The following two lines of code looks to have caused all sorts of // problems so for now we have commented them out. // screen52.getScreenFields().setCurrentField(null); // set it to null // for GC ? // screen52.clearTable(); try { writeGDS(0, 3, sc.toByteArray()); } catch (IOException ioe) { log.warn(ioe.getMessage()); } sc = null; log.debug("Save Screen end "); }
7,532
public void run () { while (keepTrucking) { try { bk = (Stream5250)dsq.get(); } catch (InterruptedException ie) { System.out.println(" vt thread interrupted and stopping "); keepTrucking = false; continue; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); invited = false; screen52.setCursorOff();// System.out.println("operation code: " + bk.getOpCode()); if (bk == null) continue; switch (bk.getOpCode()) { case 00:// System.out.println("No operation"); break; case 1:// System.out.println("Invite Operation"); parseIncoming();// screen52.setKeyboardLocked(false); pendingUnlock = true; cursorOn = true; setInvited(); break; case 2:// System.out.println("Output Only"); parseIncoming();// System.out.println(screen52.dirty); screen52.updateDirty(); // invited = true; break; case 3:// System.out.println("Put/Get Operation"); parseIncoming();// inviteIt =true; setInvited(); if (!signedOn) { signedOn = true;// signOnSave = new char[screen52.getScreenLength()]; signOnSave = screen52.getScreenAsChars(); System.out.println("Signon saved"); } break; case 4:// System.out.println("Save Screen Operation"); parseIncoming(); break; case 5:// System.out.println("Restore Screen Operation"); parseIncoming(); break; case 6:// System.out.println("Read Immediate"); sendAidKey(0); break; case 7:// System.out.println("Reserved"); break; case 8:// System.out.println("Read Screen Operation"); try { readScreen(); } catch (IOException ex) { } break; case 9:// System.out.println("Reserved"); break; case 10:// System.out.println("Cancel Invite Operation"); cancelInvite(); break; case 11:// System.out.println("Turn on message light"); screen52.setMessageLightOn(); screen52.setCursorOn(); break; case 12:// System.out.println("Turn off Message light"); screen52.setMessageLightOff(); screen52.setCursorOn(); break; default: break; } if (screen52.isUsingGuiInterface()) screen52.drawFields();// if (screen52.screen[0][1].getChar() == '#' &&// screen52.screen[0][2].getChar() == '!')// execCmd();// else { if (screen52.isHotSpots()) { screen52.checkHotSpots(); } try {// SwingUtilities.invokeAndWait(// new Runnable () {// public void run() {// screen52.updateDirty();// }// }// ); screen52.updateDirty(); } catch (Exception exd ) { System.out.println(" tnvt.run: " + exd.getMessage()); exd.printStackTrace(); } if (pendingUnlock) screen52.setKeyboardLocked(false); if (cursorOn && !screen52.isKeyboardLocked()) { screen52.setCursorOn(); cursorOn = false; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); } }
public void run () { while (keepTrucking) { try { bk = (Stream5250)dsq.get(); } catch (InterruptedException ie) { System.out.println(" vt thread interrupted and stopping "); keepTrucking = false; continue; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); invited = false; screen52.setCursorOff();// System.out.println("operation code: " + bk.getOpCode()); if (bk == null) continue; switch (bk.getOpCode()) { case 00:// System.out.println("No operation"); break; case 1:// System.out.println("Invite Operation"); parseIncoming();// screen52.setKeyboardLocked(false); pendingUnlock = true; cursorOn = true; setInvited(); break; case 2:// System.out.println("Output Only"); parseIncoming();// System.out.println(screen52.dirty); screen52.updateDirty(); // invited = true; break; case 3:// System.out.println("Put/Get Operation"); parseIncoming();// inviteIt =true; setInvited(); if (!signedOn) { signedOn = true;// signOnSave = new char[screen52.getScreenLength()]; signOnSave = screen52.getScreenAsChars(); System.out.println("Signon saved"); } break; case 4:// System.out.println("Save Screen Operation"); parseIncoming(); break; case 5:// System.out.println("Restore Screen Operation"); parseIncoming(); break; case 6:// System.out.println("Read Immediate"); sendAidKey(0); break; case 7:// System.out.println("Reserved"); break; case 8:// System.out.println("Read Screen Operation"); try { readScreen(); } catch (IOException ex) { } break; case 9:// System.out.println("Reserved"); break; case 10:// System.out.println("Cancel Invite Operation"); cancelInvite(); break; case 11:// System.out.println("Turn on message light"); screen52.setMessageLightOn(); screen52.setCursorOn(); break; case 12:// System.out.println("Turn off Message light"); screen52.setMessageLightOff(); screen52.setCursorOn(); break; default: break; } if (screen52.isUsingGuiInterface()) screen52.drawFields();// if (screen52.screen[0][1].getChar() == '#' &&// screen52.screen[0][2].getChar() == '!')// execCmd();// else { if (screen52.isHotSpots()) { screen52.checkHotSpots(); } try {// SwingUtilities.invokeAndWait(// new Runnable () {// public void run() {// screen52.updateDirty();// }// }// ); screen52.updateDirty(); } catch (Exception exd ) { System.out.println(" tnvt.run: " + exd.getMessage()); exd.printStackTrace(); } if (pendingUnlock && !screen52.isStatusErrorCode()) { screen52.setKeyboardLocked(false); if (cursorOn && !screen52.isKeyboardLocked()) { screen52.setCursorOn(); cursorOn = false; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); } }
7,533
public void sendNegResponse2(int ec) { baosp.write(0x00); baosp.write(ec); try { writeGDS(1, 0, baosp.toByteArray()); } catch (IOException ioe) { System.out.println(ioe.getMessage()); } baosp.reset(); }
screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); publicscreen52.setPrehelpState(true); voidscreen52.setPrehelpState(true); sendNegResponse2(intscreen52.setPrehelpState(true); ec)screen52.setPrehelpState(true); {screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); baosp.write(0x00);screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); baosp.write(ec);screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); tryscreen52.setPrehelpState(true); {screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); writeGDS(1,screen52.setPrehelpState(true); 0,screen52.setPrehelpState(true); baosp.toByteArray());screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); }screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); catchscreen52.setPrehelpState(true); (IOExceptionscreen52.setPrehelpState(true); ioe)screen52.setPrehelpState(true); {screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); System.out.println(ioe.getMessage());screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); }screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); baosp.reset();screen52.setPrehelpState(true); screen52.setPrehelpState(true); screen52.setPrehelpState(true); }
7,535
private final void writeErrorCode() throws Exception { screen52.goto_XY(screen52.getErrorLine(),1); // Skip the control byte screen52.saveErrorLine(); screen52.setStatus(screen52.STATUS_ERROR_CODE,screen52.STATUS_VALUE_ON,null); cursorOn = true; }
private final void writeErrorCode() throws Exception { screen52.goto_XY(screen52.getErrorLine(),1); // Skip the control byte screen52.saveErrorLine(); cursorOn = true; }
7,536
private final void writeErrorCodeToWindow() throws Exception { int fromCol = bk.getNextByte() & 0xff; // from column int toCol = bk.getNextByte() & 0xff; // to column screen52.goto_XY(screen52.getErrorLine(),fromCol); // Skip the control byte screen52.saveErrorLine(); screen52.setStatus(screen52.STATUS_ERROR_CODE,screen52.STATUS_VALUE_ON,null); cursorOn = true; }
private final void writeErrorCodeToWindow() throws Exception { int fromCol = bk.getNextByte() & 0xff; // from column int toCol = bk.getNextByte() & 0xff; // to column screen52.goto_XY(screen52.getErrorLine(),fromCol); // Skip the control byte screen52.saveErrorLine(); cursorOn = true; }
7,537
public UnresolvedObjectRefException(String s) { super(s); }
public UnresolvedObjectRefException(String s) { super(s); }
7,538
public static Properties getInitProperties() { final String arch; arch = Unsafe.getCurrentProcessor().getArchitecture().getName(); Unsafe.debug("arch="); Unsafe.debug(arch); final Properties res = new Properties(); res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", "0.1.5"); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch); res.put("os.version", "0.1.5"); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); return res; }
public static Properties getInitProperties() { final String arch; arch = Unsafe.getCurrentProcessor().getArchitecture().getName(); Unsafe.debug("arch="); Unsafe.debug(arch); final Properties res = new Properties(); res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", vm.getVersion()); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch); res.put("os.version", "0.1.5"); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); return res; }
7,539
public static Properties getInitProperties() { final String arch; arch = Unsafe.getCurrentProcessor().getArchitecture().getName(); Unsafe.debug("arch="); Unsafe.debug(arch); final Properties res = new Properties(); res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", "0.1.5"); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch); res.put("os.version", "0.1.5"); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); return res; }
public static Properties getInitProperties() { final String arch; arch = Unsafe.getCurrentProcessor().getArchitecture().getName(); Unsafe.debug("arch="); Unsafe.debug(arch); final Properties res = new Properties(); res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", "0.1.5"); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch); res.put("os.version", vm.getVersion()); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); return res; }
7,540
protected void addImpl(Component comp, Object constraints, int index) { // If we're adding in the initialization stage use super.add. // otherwise pass the add onto the content pane. if (!initStageDone) super.addImpl(comp, constraints, index); else { if (isRootPaneCheckingEnabled()) throw new Error("Do not use add() on JWindow directly. Use " + "getContentPane().add() instead"); getContentPane().add(comp, constraints, index); } }
protected void addImpl(Component comp, Object constraints, int index) { // If we're adding in the initialization stage use super.add. // otherwise pass the add onto the content pane. if (!initStageDone) super.addImpl(comp, constraints, index); else { if (isRootPaneCheckingEnabled()) throw new Error("Do not use add() on JWindow directly. Use " + "getContentPane().add() instead"); getContentPane().add(comp, constraints, index); } }
7,541
protected void addImpl(Component comp, Object constraints, int index) { // If we're adding in the initialization stage use super.add. // otherwise pass the add onto the content pane. if (!initStageDone) super.addImpl(comp, constraints, index); else { if (isRootPaneCheckingEnabled()) throw new Error("Do not use add() on JWindow directly. Use " + "getContentPane().add() instead"); getContentPane().add(comp, constraints, index); } }
protected void addImpl(Component comp, Object constraints, int index) { // If we're adding in the initialization stage use super.add. // otherwise pass the add onto the content pane. if (!initStageDone) super.addImpl(comp, constraints, index); else { if (isRootPaneCheckingEnabled()) throw new Error("Do not use add() on JWindow directly. Use " + "getContentPane().add() instead"); getContentPane().add(comp, constraints, index); } }
7,542
public void setLayout(LayoutManager manager) { // Check if we're in initialization stage. If so, call super.setLayout // otherwise, valid calls go to the content pane. if (initStageDone) { if (isRootPaneCheckingEnabled()) throw new Error("Cannot set layout. Use getContentPane().setLayout()" + " instead."); getContentPane().setLayout(manager); } else super.setLayout(manager); }
public void setLayout(LayoutManager manager) { // Check if we're in initialization stage. If so, call super.setLayout // otherwise, valid calls go to the content pane. if (initStageDone) { if (isRootPaneCheckingEnabled()) throw new Error("Cannot set layout. Use getContentPane().setLayout()" + " instead."); getContentPane().setLayout(manager); } else super.setLayout(manager); }
7,543
public void setLayout(LayoutManager manager) { // Check if we're in initialization stage. If so, call super.setLayout // otherwise, valid calls go to the content pane. if (initStageDone) { if (isRootPaneCheckingEnabled()) throw new Error("Cannot set layout. Use getContentPane().setLayout()" + " instead."); getContentPane().setLayout(manager); } else super.setLayout(manager); }
public void setLayout(LayoutManager manager) { // Check if we're in initialization stage. If so, call super.setLayout // otherwise, valid calls go to the content pane. if (initStageDone) { if (isRootPaneCheckingEnabled()) throw new Error("Cannot set layout. Use getContentPane().setLayout()" + " instead."); getContentPane().setLayout(manager); } else super.setLayout(manager); }
7,544
public void setLayout(LayoutManager manager) { // Check if we're in initialization stage. If so, call super.setLayout // otherwise, valid calls go to the content pane. if (initStageDone) { if (isRootPaneCheckingEnabled()) throw new Error("Cannot set layout. Use getContentPane().setLayout()" + " instead."); getContentPane().setLayout(manager); } else super.setLayout(manager); }
public void setLayout(LayoutManager manager) { // Check if we're in initialization stage. If so, call super.setLayout // otherwise, valid calls go to the content pane. if (initStageDone) { if (isRootPaneCheckingEnabled()) throw new Error("Cannot set layout. Use getContentPane().setLayout()" + " instead."); getContentPane().setLayout(manager); else super.setLayout(manager); }
7,545
protected void windowInit() { super.setLayout(new BorderLayout(1, 1)); getRootPane(); // will do set/create // Now we're done init stage, adds and layouts go to content pane. initStageDone = true; }
protected void windowInit() { super.setLayout(new BorderLayout(1, 1)); getRootPane(); // will do set/create // Now we're done init stage, adds and layouts go to content pane. setRootPaneCheckingEnabled(true); }
7,546
private void nextSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = desktop.getSelectedFrame(); int index = desktop.getIndexOf(miv); MyInternalFrame mix = (MyInternalFrame)frames[index]; int seq = mix.getInternalId(); index = 0; for (int x = 0; x < frames.length; x++){ MyInternalFrame mif = (MyInternalFrame)frames[x]; System.out.println(" current index " + x + " count " + frames.length + " has focus " + mif.isActive() + " title " + mif.getTitle()); if (mif.getInternalId() > seq) { index = x; break; } } System.out.println(" current index " + index + " count " + desktop.getComponentCount()); if (index < desktop.getComponentCount() - 1) { try { frames[index].setSelected(true); } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } else { try { frames[0].setSelected(true); } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } }
private void nextSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = desktop.getSelectedFrame(); int index = desktop.getIndexOf(miv); MyInternalFrame mix = (MyInternalFrame)frames[index]; int seq = mix.getInternalId(); index = 0; for (int x = 0; x < frames.length; x++){ MyInternalFrame mif = (MyInternalFrame)frames[x]; System.out.println(" current index " + x + " count " + frames.length + " has focus " + mif.isActive() + " title " + mif.getTitle()); if (mif.getInternalId() > seq) { index = x; break; } } System.out.println(" current index " + index + " count " + desktop.getComponentCount()); if (index < desktop.getComponentCount() - 1) { try { frames[index].setSelected(true); } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } else { try { frames[0].setSelected(true); } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } }
7,549
private void nextSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = desktop.getSelectedFrame(); int index = desktop.getIndexOf(miv); MyInternalFrame mix = (MyInternalFrame)frames[index]; int seq = mix.getInternalId(); index = 0; for (int x = 0; x < frames.length; x++){ MyInternalFrame mif = (MyInternalFrame)frames[x]; System.out.println(" current index " + x + " count " + frames.length + " has focus " + mif.isActive() + " title " + mif.getTitle()); if (mif.getInternalId() > seq) { index = x; break; } } System.out.println(" current index " + index + " count " + desktop.getComponentCount()); if (index < desktop.getComponentCount() - 1) { try { frames[index].setSelected(true); } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } else { try { frames[0].setSelected(true); } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } }
private void nextSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = desktop.getSelectedFrame(); int index = desktop.getIndexOf(miv); MyInternalFrame mix = (MyInternalFrame)frames[index]; int seq = mix.getInternalId(); index = 0; for (int x = 0; x < frames.length; x++){ MyInternalFrame mif = (MyInternalFrame)frames[x]; System.out.println(" current index " + x + " count " + frames.length + " has focus " + mif.isActive() + " title " + mif.getTitle()); if (mif.getInternalId() > seq) { index = x; break; } } System.out.println(" current index " + index + " count " + desktop.getComponentCount()); if (index < desktop.getComponentCount() - 1) { try { frames[index].setSelected(true); } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } else { try { frames[0].setSelected(true); } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } }
7,550
private void prevSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = (JInternalFrame)desktop.getSelectedFrame();// int index = desktop.getIndexOf(miv); int index = selectedIndex; if (index == 0) {// desktop.setSelectedFrame(frames[frames.length - 1]); try { frames[frames.length - 1].setSelected(true); frames[frames.length - 1].repaint(); selectedIndex = frames.length -1; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } else { try { frames[index - 1].setSelected(true); frames[index - 1].repaint(); selectedIndex--; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } }
private void prevSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = (JInternalFrame)desktop.getSelectedFrame();// int index = desktop.getIndexOf(miv); int index = selectedIndex; if (index == 0) {// desktop.setSelectedFrame(frames[frames.length - 1]); try { frames[frames.length - 1].setSelected(true); frames[frames.length - 1].repaint(); selectedIndex = frames.length -1; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } else { try { frames[index - 1].setSelected(true); frames[index - 1].repaint(); selectedIndex--; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } }
7,552
private void prevSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = (JInternalFrame)desktop.getSelectedFrame();// int index = desktop.getIndexOf(miv); int index = selectedIndex; if (index == 0) {// desktop.setSelectedFrame(frames[frames.length - 1]); try { frames[frames.length - 1].setSelected(true); frames[frames.length - 1].repaint(); selectedIndex = frames.length -1; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } else { try { frames[index - 1].setSelected(true); frames[index - 1].repaint(); selectedIndex--; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } }
private void prevSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = (JInternalFrame)desktop.getSelectedFrame();// int index = desktop.getIndexOf(miv); int index = selectedIndex; if (index == 0) {// desktop.setSelectedFrame(frames[frames.length - 1]); try { frames[frames.length - 1].setSelected(true); frames[frames.length - 1].repaint(); selectedIndex = frames.length -1; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } else { try { frames[index - 1].setSelected(true); frames[index - 1].repaint(); selectedIndex--; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } }
7,553
private void prevSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = (JInternalFrame)desktop.getSelectedFrame();// int index = desktop.getIndexOf(miv); int index = selectedIndex; if (index == 0) {// desktop.setSelectedFrame(frames[frames.length - 1]); try { frames[frames.length - 1].setSelected(true); frames[frames.length - 1].repaint(); selectedIndex = frames.length -1; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } else { try { frames[index - 1].setSelected(true); frames[index - 1].repaint(); selectedIndex--; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } }
private void prevSession() { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); JInternalFrame miv = (JInternalFrame)desktop.getSelectedFrame();// int index = desktop.getIndexOf(miv); int index = selectedIndex; if (index == 0) {// desktop.setSelectedFrame(frames[frames.length - 1]); try { frames[frames.length - 1].setSelected(true); frames[frames.length - 1].repaint(); selectedIndex = frames.length -1; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } else { try { frames[index - 1].setSelected(true); frames[index - 1].repaint(); selectedIndex--; } catch (java.beans.PropertyVetoException e) { System.out.println(e.getMessage()); } } }
7,554
public void removeSessionView(Session targetSession) { int index = getIndexOfSession(targetSession); System.out.println("session found and closing down " + index); targetSession.removeSessionListener(this); targetSession.removeSessionJumpListener(this); desktop.remove(index); this.repaint(); }
public void removeSessionView(Session targetSession) { int index = getIndexOfSession(targetSession); System.out.println("session found and closing down " + index); targetSession.removeSessionListener(this); targetSession.removeSessionJumpListener(this); this.repaint(); }
7,556
private HashMap getEntries() throws IOException { synchronized(raf) { if (closed) throw new IllegalStateException("ZipFile has closed: " + name); if (entries == null) readEntries(); return entries; } }
private HashMap getEntries() throws IOException { synchronized(raf) { if (closed) throw new IllegalStateException("ZipFile has closed: " + name); if (entries == null) readEntries(); return entries; } }
7,557
private int indexOfCRLF(byte[] b, int off, int len) throws IOException { doReset = false; int lm1 = len - 1; for (int i = off; i < len; i++) { if (b[i] == CR) { int d; if (i == lm1) { d = in.read(); doReset = true; } else { d = b[i + 1]; } if (d == LF) { doReset = true; return i; } } } return -1; }
private int indexOfCRLF(byte[] b, int off, int len) throws IOException { doReset = false; int lm1 = len - 1; for (int i = off; i < len; i++) { if (b[i] == CR) { int d; if (i == lm1) { d = in.read(); doReset = true; } else { d = b[i + 1]; } if (d == LF) { doReset = true; return i; } } } return -1; }
7,559
private int indexOfCRLF(byte[] b, int off, int len) throws IOException { doReset = false; int lm1 = len - 1; for (int i = off; i < len; i++) { if (b[i] == CR) { int d; if (i == lm1) { d = in.read(); doReset = true; } else { d = b[i + 1]; } if (d == LF) { doReset = true; return i; } } } return -1; }
private int indexOfCRLF(byte[] b, int off, int len) throws IOException { doReset = false; int lm1 = len - 1; for (int i = off; i < len; i++) { if (b[i] == CR) { int d; if (i == em1) { d = in.read(); doReset = true; } else { d = b[i + 1]; } if (d == LF) { doReset = true; return i; } } } return -1; }
7,560
public boolean action(Event evt, Object what) { // XXX Add backward compatibility handling. return false; }
publicbooleanaction(Eventevt,Objectwhat){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,561
private PaintEvent coalescePaintEvents(PaintEvent queuedEvent, PaintEvent newEvent) { Rectangle r1 = queuedEvent.getUpdateRect(); Rectangle r2 = newEvent.getUpdateRect(); Rectangle union = r1.union(r2); int r1a = r1.width * r1.height; int r2a = r2.width * r2.height; int ua = union.width * union.height; if (ua > (r1a+r2a)*2) return null; /* The 2 factor should maybe be reconsidered. Perhaps 3/2 would be better? */ newEvent.setUpdateRect(union); return newEvent; }
private PaintEvent coalescePaintEvents(PaintEvent queuedEvent, PaintEvent newEvent) { Rectangle r1 = queuedEvent.getUpdateRect(); Rectangle r2 = newEvent.getUpdateRect(); Rectangle union = r1.union(r2); int r1a = r1.width * r1.height; int r2a = r2.width * r2.height; int ua = union.width * union.height; if (ua > (r1a+r2a)*2) return null; /* The 2 factor should maybe be reconsidered. Perhaps 3/2 would be better? */ newEvent.setUpdateRect(union); return newEvent; }
7,562
private PaintEvent coalescePaintEvents(PaintEvent queuedEvent, PaintEvent newEvent) { Rectangle r1 = queuedEvent.getUpdateRect(); Rectangle r2 = newEvent.getUpdateRect(); Rectangle union = r1.union(r2); int r1a = r1.width * r1.height; int r2a = r2.width * r2.height; int ua = union.width * union.height; if (ua > (r1a+r2a)*2) return null; /* The 2 factor should maybe be reconsidered. Perhaps 3/2 would be better? */ newEvent.setUpdateRect(union); return newEvent; }
private PaintEvent coalescePaintEvents(PaintEvent queuedEvent, PaintEvent newEvent) { Rectangle r1 = queuedEvent.getUpdateRect(); Rectangle r2 = newEvent.getUpdateRect(); Rectangle union = r1.union(r2); int r1a = r1.width * r1.height; int r2a = r2.width * r2.height; int ua = union.width * union.height; if (ua > (r1a+r2a)*2) return null; /* The 2 factor should maybe be reconsidered. Perhaps 3/2 would be better? */ newEvent.setUpdateRect(union); return newEvent; }
7,563
private PaintEvent coalescePaintEvents(PaintEvent queuedEvent, PaintEvent newEvent) { Rectangle r1 = queuedEvent.getUpdateRect(); Rectangle r2 = newEvent.getUpdateRect(); Rectangle union = r1.union(r2); int r1a = r1.width * r1.height; int r2a = r2.width * r2.height; int ua = union.width * union.height; if (ua > (r1a+r2a)*2) return null; /* The 2 factor should maybe be reconsidered. Perhaps 3/2 would be better? */ newEvent.setUpdateRect(union); return newEvent; }
private PaintEvent coalescePaintEvents(PaintEvent queuedEvent, PaintEvent newEvent) { Rectangle r1 = queuedEvent.getUpdateRect(); Rectangle r2 = newEvent.getUpdateRect(); Rectangle union = r1.union(r2); int r1a = r1.width * r1.height; int r2a = r2.width * r2.height; int ua = union.width * union.height; if (ua > (r1a+r2a)*2) return null; /* The 2 factor should maybe be reconsidered. Perhaps 3/2 would be better? */ newEvent.setUpdateRect(union); return newEvent; }
7,564
private PaintEvent coalescePaintEvents(PaintEvent queuedEvent, PaintEvent newEvent) { Rectangle r1 = queuedEvent.getUpdateRect(); Rectangle r2 = newEvent.getUpdateRect(); Rectangle union = r1.union(r2); int r1a = r1.width * r1.height; int r2a = r2.width * r2.height; int ua = union.width * union.height; if (ua > (r1a+r2a)*2) return null; /* The 2 factor should maybe be reconsidered. Perhaps 3/2 would be better? */ newEvent.setUpdateRect(union); return newEvent; }
private PaintEvent coalescePaintEvents(PaintEvent queuedEvent, PaintEvent newEvent) { Rectangle r1 = queuedEvent.getUpdateRect(); Rectangle r2 = newEvent.getUpdateRect(); Rectangle union = r1.union(r2); int r1a = r1.width * r1.height; int r2a = r2.width * r2.height; int ua = union.width * union.height; if (ua > (r1a+r2a)*2) return null; /* The 2 factor should maybe be reconsidered. Perhaps 3/2 would be better? */ newEvent.setUpdateRect(union); return newEvent; }
7,565
public boolean gotFocus(Event evt, Object what) { // XXX Add backward compatibility handling. return false; }
publicbooleangotFocus(Eventevt,Objectwhat){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,566
public boolean keyDown(Event evt, int key) { // XXX Add backward compatibility handling. return false; }
publicbooleankeyDown(Eventevt,intkey){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,567
public boolean keyUp(Event evt, int key) { // XXX Add backward compatibility handling. return false; }
publicbooleankeyUp(Eventevt,intkey){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,568
public boolean lostFocus(Event evt, Object what) { // XXX Add backward compatibility handling. return false; }
publicbooleanlostFocus(Eventevt,Objectwhat){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,569
public boolean mouseDown(Event evt, int x, int y) { // XXX Add backward compatibility handling. return false; }
publicbooleanmouseDown(Eventevt,intx,inty){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,570
public boolean mouseDrag(Event evt, int x, int y) { // XXX Add backward compatibility handling. return false; }
publicbooleanmouseDrag(Eventevt,intx,inty){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,571
public boolean mouseEnter(Event evt, int x, int y) { // XXX Add backward compatibility handling. return false; }
publicbooleanmouseEnter(Eventevt,intx,inty){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,572
public boolean mouseExit(Event evt, int x, int y) { // XXX Add backward compatibility handling. return false; }
publicbooleanmouseExit(Eventevt,intx,inty){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,573
public boolean mouseMove(Event evt, int x, int y) { // XXX Add backward compatibility handling. return false; }
publicbooleanmouseMove(Eventevt,intx,inty){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,574
public boolean mouseUp(Event evt, int x, int y) { // XXX Add backward compatibility handling. return false; }
publicbooleanmouseUp(Eventevt,intx,inty){ //XXXAddbackwardcompatibilityhandling. returnfalse; }
7,575
public void move(int x, int y) { int oldx = this.x; int oldy = this.y; if (this.x == x && this.y == y) return; invalidate (); this.x = x; this.y = y; if (peer != null) peer.setBounds (x, y, width, height); // Erase old bounds and repaint new bounds for lightweights. if (isLightweight() && width != 0 && height !=0) { parent.repaint(oldx, oldy, width, height); repaint(); } if (oldx != x || oldy != y) { ComponentEvent ce = new ComponentEvent(this, ComponentEvent.COMPONENT_MOVED); getToolkit().getSystemEventQueue().postEvent(ce); } }
public void move(int x, int y) { int oldx = this.x; int oldy = this.y; if (this.x == x && this.y == y) return; invalidate (); this.x = x; this.y = y; if (peer != null) peer.setBounds (x, y, width, height); // Erase old bounds and repaint new bounds for lightweights. if (isLightweight() && width != 0 && height !=0) { parent.repaint(oldx, oldy, width, height); repaint(); } if (oldx != x || oldy != y) { ComponentEvent ce = new ComponentEvent(this, ComponentEvent.COMPONENT_MOVED); getToolkit().getSystemEventQueue().postEvent(ce); } }
7,576
public void resize(int width, int height) { int oldwidth = this.width; int oldheight = this.height; if (this.width == width && this.height == height) return; invalidate (); this.width = width; this.height = height; if (peer != null) peer.setBounds (x, y, width, height); // Erase old bounds and repaint new bounds for lightweights. if (isLightweight()) { if (oldwidth != 0 && oldheight != 0 && parent != null) parent.repaint(x, y, oldwidth, oldheight); if (width != 0 && height != 0) repaint(); } if (oldwidth != width || oldheight != height) { ComponentEvent ce = new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED); getToolkit().getSystemEventQueue().postEvent(ce); } }
public void resize(int width, int height) { int oldwidth = this.width; int oldheight = this.height; if (this.width == width && this.height == height) return; invalidate (); this.width = width; this.height = height; if (peer != null) peer.setBounds (x, y, width, height); // Erase old bounds and repaint new bounds for lightweights. if (isLightweight()) { if (oldwidth != 0 && oldheight != 0 && parent != null) parent.repaint(x, y, oldwidth, oldheight); if (width != 0 && height != 0) repaint(); } if (oldwidth != width || oldheight != height) { ComponentEvent ce = new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED); getToolkit().getSystemEventQueue().postEvent(ce); } }
7,579
private void disconnectMe() { me.closeSession((Session)this.getContentPane()); }
private void disconnectMe() { Session s = (Session)getContentPane(); me.closeSession(s); }
7,581
public boolean containsSession(Session session) { return desktop.getIndexOf(session) >= 0; }
public boolean containsSession(Session session) { return getIndexOfSession(session) >= 0; }
7,582
public int getIndexOfSession(Session session) { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); int index = -1; for (int idx = 0; idx < frames.length; idx++) { if (frames[idx].getContentPane().equals(session)) { index = idx; return index; } } return index; }
public int getIndexOfSession(Session session) { JInternalFrame[] frames = (JInternalFrame[])desktop.getAllFrames(); int index = -1; for (int idx = 0; idx < frames.length; idx++) { Session ses = (Session)frames[idx].getContentPane(); if (ses.equals(session)) { index = idx; return index; } } return index; }
7,583
private void jbInit() throws Exception { desktop = new JDesktopPane(); setContentPane(desktop); // Install our custom desktop manager desktop.setDesktopManager(new MyDesktopMgr()); if (sequence > 0) setTitle("tn5250j <" + sequence + ">- " + tn5250jRelease + tn5250jVersion + tn5250jSubVer); else setTitle("tn5250j - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer); if (packFrame) pack(); else validate(); }
private void jbInit() throws Exception { desktop = new JDesktopPane(); // Install our custom desktop manager desktop.setDesktopManager(new MyDesktopMgr()); if (sequence > 0) setTitle("tn5250j <" + sequence + ">- " + tn5250jRelease + tn5250jVersion + tn5250jSubVer); else setTitle("tn5250j - " + tn5250jRelease + tn5250jVersion + tn5250jSubVer); if (packFrame) pack(); else validate(); }
7,584
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
7,586
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
7,587
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
7,588
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
7,589
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
7,590
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
7,591
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
7,592
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
public void add(int field, int amount) { switch (field) { case YEAR: complete(); fields[YEAR] += amount; isTimeSet = false; break; case MONTH: complete(); int months = fields[MONTH] + amount; fields[YEAR] += months / 12; fields[MONTH] = months % 12; if (fields[MONTH] < 0) { fields[MONTH] += 12; fields[YEAR]--; } isTimeSet = false; int maxDay = getActualMaximum(DAY_OF_MONTH); if (fields[DAY_OF_MONTH] > maxDay) { fields[DAY_OF_MONTH] = maxDay; isTimeSet = false; } break; case DAY_OF_MONTH: case DAY_OF_YEAR: case DAY_OF_WEEK: if (!isTimeSet) computeTime(); time += amount * (24 * 60 * 60 * 1000L); areFieldsSet = false; break; case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: if (!isTimeSet) computeTime(); time += amount * (7 * 24 * 60 * 60 * 1000L); areFieldsSet = false; break; case AM_PM: if (!isTimeSet) computeTime(); time += amount * (12 * 60 * 60 * 1000L); areFieldsSet = false; break; case HOUR: case HOUR_OF_DAY: if (!isTimeSet) computeTime(); time += amount * (60 * 60 * 1000L); areFieldsSet = false; break; case MINUTE: if (!isTimeSet) computeTime(); time += amount * (60 * 1000L); areFieldsSet = false; break; case SECOND: if (!isTimeSet) computeTime(); time += amount * (1000L); areFieldsSet = false; break; case MILLISECOND: if (!isTimeSet) computeTime(); time += amount; areFieldsSet = false; break; case ZONE_OFFSET: case DST_OFFSET: default: throw new IllegalArgumentException("Invalid or unknown field"); } }
7,593
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int)(day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int)(gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int)day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int)day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int)(day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int)(gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int)day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int)day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
7,594
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int)(day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int)(gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int)day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int)day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int)(day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int)(gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int)day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int)day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
7,595
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int)(day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int)(gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int)day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int)day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int)(day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int)(gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int) day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int)day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
7,596
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int)(day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int)(gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int)day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int)day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int)(day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int)(gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int)day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int)day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
7,597
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int)(day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int)(gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int)day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int)day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int)(day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int)(gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int)day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int)day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
7,598
private void cleanUpAfterRoll(int field, int delta) { switch (field) { case ERA: case YEAR: case MONTH: // check that day of month is still in correct range if (fields[DAY_OF_MONTH] > getActualMaximum(DAY_OF_MONTH)) fields[DAY_OF_MONTH] = getActualMaximum(DAY_OF_MONTH); isTimeSet = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; break; case DAY_OF_MONTH: isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (24 * 60 * 60 * 1000L); break; case WEEK_OF_MONTH: isSet[DAY_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case DAY_OF_WEEK_IN_MONTH: isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case DAY_OF_YEAR: isSet[MONTH] = false; isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (24 * 60 * 60 * 1000L); break; case WEEK_OF_YEAR: isSet[MONTH] = false; isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case AM_PM: isSet[HOUR_OF_DAY] = false; time += delta * (12 * 60 * 60 * 1000L); break; case HOUR: isSet[HOUR_OF_DAY] = false; time += delta * (60 * 60 * 1000L); break; case HOUR_OF_DAY: isSet[HOUR] = false; isSet[AM_PM] = false; time += delta * (60 * 60 * 1000L); break; case MINUTE: time += delta * (60 * 1000L); break; case SECOND: time += delta * (1000L); break; case MILLISECOND: time += delta; break; } }
privatevoidcleanUpAfterRoll(intfield,intdelta){switch(field){caseERA:caseYEAR:caseMONTH: //checkthatdayofmonthisstillincorrectrange if(fields[DAY_OF_MONTH]>getActualMaximum(DAY_OF_MONTH)) fields[DAY_OF_MONTH]=getActualMaximum(DAY_OF_MONTH); isTimeSet=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; break;caseDAY_OF_MONTH: isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(24*60*60*1000L); break;caseWEEK_OF_MONTH: isSet[DAY_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseDAY_OF_WEEK_IN_MONTH: isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseDAY_OF_YEAR: isSet[MONTH]=false; isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(24*60*60*1000L); break;caseWEEK_OF_YEAR: isSet[MONTH]=false; isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseAM_PM: isSet[HOUR_OF_DAY]=false; time+=delta*(12*60*60*1000L); break;caseHOUR: isSet[HOUR_OF_DAY]=false; time+=delta*(60*60*1000L); break;caseHOUR_OF_DAY: isSet[HOUR]=false; isSet[AM_PM]=false; time+=delta*(60*60*1000L); break;caseMINUTE: time+=delta*(60*1000L); break;caseSECOND: time+=delta*(1000L); break;caseMILLISECOND: time+=delta; break; } }
7,599
private void cleanUpAfterRoll(int field, int delta) { switch (field) { case ERA: case YEAR: case MONTH: // check that day of month is still in correct range if (fields[DAY_OF_MONTH] > getActualMaximum(DAY_OF_MONTH)) fields[DAY_OF_MONTH] = getActualMaximum(DAY_OF_MONTH); isTimeSet = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; break; case DAY_OF_MONTH: isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (24 * 60 * 60 * 1000L); break; case WEEK_OF_MONTH: isSet[DAY_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case DAY_OF_WEEK_IN_MONTH: isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case DAY_OF_YEAR: isSet[MONTH] = false; isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (24 * 60 * 60 * 1000L); break; case WEEK_OF_YEAR: isSet[MONTH] = false; isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case AM_PM: isSet[HOUR_OF_DAY] = false; time += delta * (12 * 60 * 60 * 1000L); break; case HOUR: isSet[HOUR_OF_DAY] = false; time += delta * (60 * 60 * 1000L); break; case HOUR_OF_DAY: isSet[HOUR] = false; isSet[AM_PM] = false; time += delta * (60 * 60 * 1000L); break; case MINUTE: time += delta * (60 * 1000L); break; case SECOND: time += delta * (1000L); break; case MILLISECOND: time += delta; break; } }
privatevoidcleanUpAfterRoll(intfield,intdelta){switch(field){caseERA:caseYEAR:caseMONTH: //checkthatdayofmonthisstillincorrectrange if(fields[DAY_OF_MONTH]>getActualMaximum(DAY_OF_MONTH)) fields[DAY_OF_MONTH]=getActualMaximum(DAY_OF_MONTH); isTimeSet=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; break;caseDAY_OF_MONTH: isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(24*60*60*1000L); break;caseWEEK_OF_MONTH: isSet[DAY_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseDAY_OF_WEEK_IN_MONTH: isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseDAY_OF_YEAR: isSet[MONTH]=false; isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(24*60*60*1000L); break;caseWEEK_OF_YEAR: isSet[MONTH]=false; isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseAM_PM: isSet[HOUR_OF_DAY]=false; time+=delta*(12*60*60*1000L); break;caseHOUR: isSet[HOUR_OF_DAY]=false; time+=delta*(60*60*1000L); break;caseHOUR_OF_DAY: isSet[HOUR]=false; isSet[AM_PM]=false; time+=delta*(60*60*1000L); break;caseMINUTE: time+=delta*(60*1000L); break;caseSECOND: time+=delta*(1000L); break;caseMILLISECOND: time+=delta; break; } }
7,600
private void cleanUpAfterRoll(int field, int delta) { switch (field) { case ERA: case YEAR: case MONTH: // check that day of month is still in correct range if (fields[DAY_OF_MONTH] > getActualMaximum(DAY_OF_MONTH)) fields[DAY_OF_MONTH] = getActualMaximum(DAY_OF_MONTH); isTimeSet = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; break; case DAY_OF_MONTH: isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (24 * 60 * 60 * 1000L); break; case WEEK_OF_MONTH: isSet[DAY_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case DAY_OF_WEEK_IN_MONTH: isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case DAY_OF_YEAR: isSet[MONTH] = false; isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (24 * 60 * 60 * 1000L); break; case WEEK_OF_YEAR: isSet[MONTH] = false; isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case AM_PM: isSet[HOUR_OF_DAY] = false; time += delta * (12 * 60 * 60 * 1000L); break; case HOUR: isSet[HOUR_OF_DAY] = false; time += delta * (60 * 60 * 1000L); break; case HOUR_OF_DAY: isSet[HOUR] = false; isSet[AM_PM] = false; time += delta * (60 * 60 * 1000L); break; case MINUTE: time += delta * (60 * 1000L); break; case SECOND: time += delta * (1000L); break; case MILLISECOND: time += delta; break; } }
privatevoidcleanUpAfterRoll(intfield,intdelta){switch(field){caseERA:caseYEAR:caseMONTH: //checkthatdayofmonthisstillincorrectrange if(fields[DAY_OF_MONTH]>getActualMaximum(DAY_OF_MONTH)) fields[DAY_OF_MONTH]=getActualMaximum(DAY_OF_MONTH); isTimeSet=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; break;caseDAY_OF_MONTH: isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(24*60*60*1000L); break;caseWEEK_OF_MONTH: isSet[DAY_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseDAY_OF_WEEK_IN_MONTH: isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseDAY_OF_YEAR: isSet[MONTH]=false; isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(24*60*60*1000L); break;caseWEEK_OF_YEAR: isSet[MONTH]=false; isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseAM_PM: isSet[HOUR_OF_DAY]=false; time+=delta*(12*60*60*1000L); break;caseHOUR: isSet[HOUR_OF_DAY]=false; time+=delta*(60*60*1000L); break;caseHOUR_OF_DAY: isSet[HOUR]=false; isSet[AM_PM]=false; time+=delta*(60*60*1000L); break;caseMINUTE: time+=delta*(60*1000L); break;caseSECOND: time+=delta*(1000L); break;caseMILLISECOND: time+=delta; break; } }
7,601
private void cleanUpAfterRoll(int field, int delta) { switch (field) { case ERA: case YEAR: case MONTH: // check that day of month is still in correct range if (fields[DAY_OF_MONTH] > getActualMaximum(DAY_OF_MONTH)) fields[DAY_OF_MONTH] = getActualMaximum(DAY_OF_MONTH); isTimeSet = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; break; case DAY_OF_MONTH: isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (24 * 60 * 60 * 1000L); break; case WEEK_OF_MONTH: isSet[DAY_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case DAY_OF_WEEK_IN_MONTH: isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case DAY_OF_YEAR: isSet[MONTH] = false; isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[WEEK_OF_YEAR] = false; time += delta * (24 * 60 * 60 * 1000L); break; case WEEK_OF_YEAR: isSet[MONTH] = false; isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; time += delta * (7 * 24 * 60 * 60 * 1000L); break; case AM_PM: isSet[HOUR_OF_DAY] = false; time += delta * (12 * 60 * 60 * 1000L); break; case HOUR: isSet[HOUR_OF_DAY] = false; time += delta * (60 * 60 * 1000L); break; case HOUR_OF_DAY: isSet[HOUR] = false; isSet[AM_PM] = false; time += delta * (60 * 60 * 1000L); break; case MINUTE: time += delta * (60 * 1000L); break; case SECOND: time += delta * (1000L); break; case MILLISECOND: time += delta; break; } }
privatevoidcleanUpAfterRoll(intfield,intdelta){switch(field){caseERA:caseYEAR:caseMONTH: //checkthatdayofmonthisstillincorrectrange if(fields[DAY_OF_MONTH]>getActualMaximum(DAY_OF_MONTH)) fields[DAY_OF_MONTH]=getActualMaximum(DAY_OF_MONTH); isTimeSet=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; break;caseDAY_OF_MONTH: isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(24*60*60*1000L); break;caseWEEK_OF_MONTH: isSet[DAY_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseDAY_OF_WEEK_IN_MONTH: isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_YEAR]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseDAY_OF_YEAR: isSet[MONTH]=false; isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_WEEK]=false; isSet[WEEK_OF_YEAR]=false; time+=delta*(24*60*60*1000L); break;caseWEEK_OF_YEAR: isSet[MONTH]=false; isSet[DAY_OF_MONTH]=false; isSet[WEEK_OF_MONTH]=false; isSet[DAY_OF_WEEK_IN_MONTH]=false; isSet[DAY_OF_YEAR]=false; time+=delta*(7*24*60*60*1000L); break;caseAM_PM: isSet[HOUR_OF_DAY]=false; time+=delta*(12*60*60*1000L); break;caseHOUR: isSet[HOUR_OF_DAY]=false; time+=delta*(60*60*1000L); break;caseHOUR_OF_DAY: isSet[HOUR]=false; isSet[AM_PM]=false; time+=delta*(60*60*1000L); break;caseMINUTE: time+=delta*(60*1000L); break;caseSECOND: time+=delta*(1000L); break;caseMILLISECOND: time+=delta; break; } }
7,602
protected synchronized void computeFields() { boolean gregorian = (time >= gregorianCutover); TimeZone zone = getTimeZone(); fields[ZONE_OFFSET] = zone.getRawOffset(); long localTime = time + fields[ZONE_OFFSET]; long day = localTime / (24 * 60 * 60 * 1000L); int millisInDay = (int) (localTime % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } calculateDay(fields, day, gregorian); fields[DST_OFFSET] = zone.getOffset(fields[ERA], fields[YEAR], fields[MONTH], fields[DAY_OF_MONTH], fields[DAY_OF_WEEK], millisInDay) - fields[ZONE_OFFSET]; millisInDay += fields[DST_OFFSET]; if (millisInDay >= 24 * 60 * 60 * 1000) { millisInDay -= 24 * 60 * 60 * 1000; calculateDay(fields, ++day, gregorian); } fields[DAY_OF_WEEK_IN_MONTH] = (fields[DAY_OF_MONTH] + 6) / 7; // which day of the week are we (0..6), relative to getFirstDayOfWeek int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7; fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7; int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7; // Do the Correction: getMinimalDaysInFirstWeek() is always in the // first week. int minDays = getMinimalDaysInFirstWeek(); int firstWeekday = (7 + getWeekDay(fields[YEAR], minDays) - getFirstDayOfWeek()) % 7; if (minDays - firstWeekday < 1) weekOfYear++; fields[WEEK_OF_YEAR] = weekOfYear; int hourOfDay = millisInDay / (60 * 60 * 1000); fields[AM_PM] = (hourOfDay < 12) ? AM : PM; int hour = hourOfDay % 12; fields[HOUR] = (hour == 0) ? 12 : hour; fields[HOUR_OF_DAY] = hourOfDay; millisInDay %= (60 * 60 * 1000); fields[MINUTE] = millisInDay / (60 * 1000); millisInDay %= (60 * 1000); fields[SECOND] = millisInDay / (1000); fields[MILLISECOND] = millisInDay % 1000; areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true; }
protected synchronized void computeFields() { boolean gregorian = (time >= gregorianCutover); TimeZone zone = getTimeZone(); fields[ZONE_OFFSET] = zone.getRawOffset(); long localTime = time + fields[ZONE_OFFSET]; long day = localTime / (24 * 60 * 60 * 1000L); int millisInDay = (int) (localTime % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } calculateDay(fields, day, gregorian); fields[DST_OFFSET] = zone.getOffset(fields[ERA], fields[YEAR], fields[MONTH], fields[DAY_OF_MONTH], fields[DAY_OF_WEEK], millisInDay) - fields[ZONE_OFFSET]; millisInDay += fields[DST_OFFSET]; if (millisInDay >= 24 * 60 * 60 * 1000) { millisInDay -= 24 * 60 * 60 * 1000; calculateDay(fields, ++day, gregorian); } fields[DAY_OF_WEEK_IN_MONTH] = (fields[DAY_OF_MONTH] + 6) / 7; // which day of the week are we (0..6), relative to getFirstDayOfWeek int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7; fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7; int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7; // Do the Correction: getMinimalDaysInFirstWeek() is always in the // first week. int minDays = getMinimalDaysInFirstWeek(); int firstWeekday = (7 + getWeekDay(fields[YEAR], minDays) - getFirstDayOfWeek()) % 7; if (minDays - firstWeekday < 1) weekOfYear++; fields[WEEK_OF_YEAR] = weekOfYear; int hourOfDay = millisInDay / (60 * 60 * 1000); fields[AM_PM] = (hourOfDay < 12) ? AM : PM; int hour = hourOfDay % 12; fields[HOUR] = (hour == 0) ? 12 : hour; fields[HOUR_OF_DAY] = hourOfDay; millisInDay %= (60 * 60 * 1000); fields[MINUTE] = millisInDay / (60 * 1000); millisInDay %= (60 * 1000); fields[SECOND] = millisInDay / (1000); fields[MILLISECOND] = millisInDay % 1000; areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true; }
7,603
protected synchronized void computeFields() { boolean gregorian = (time >= gregorianCutover); TimeZone zone = getTimeZone(); fields[ZONE_OFFSET] = zone.getRawOffset(); long localTime = time + fields[ZONE_OFFSET]; long day = localTime / (24 * 60 * 60 * 1000L); int millisInDay = (int) (localTime % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } calculateDay(fields, day, gregorian); fields[DST_OFFSET] = zone.getOffset(fields[ERA], fields[YEAR], fields[MONTH], fields[DAY_OF_MONTH], fields[DAY_OF_WEEK], millisInDay) - fields[ZONE_OFFSET]; millisInDay += fields[DST_OFFSET]; if (millisInDay >= 24 * 60 * 60 * 1000) { millisInDay -= 24 * 60 * 60 * 1000; calculateDay(fields, ++day, gregorian); } fields[DAY_OF_WEEK_IN_MONTH] = (fields[DAY_OF_MONTH] + 6) / 7; // which day of the week are we (0..6), relative to getFirstDayOfWeek int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7; fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7; int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7; // Do the Correction: getMinimalDaysInFirstWeek() is always in the // first week. int minDays = getMinimalDaysInFirstWeek(); int firstWeekday = (7 + getWeekDay(fields[YEAR], minDays) - getFirstDayOfWeek()) % 7; if (minDays - firstWeekday < 1) weekOfYear++; fields[WEEK_OF_YEAR] = weekOfYear; int hourOfDay = millisInDay / (60 * 60 * 1000); fields[AM_PM] = (hourOfDay < 12) ? AM : PM; int hour = hourOfDay % 12; fields[HOUR] = (hour == 0) ? 12 : hour; fields[HOUR_OF_DAY] = hourOfDay; millisInDay %= (60 * 60 * 1000); fields[MINUTE] = millisInDay / (60 * 1000); millisInDay %= (60 * 1000); fields[SECOND] = millisInDay / (1000); fields[MILLISECOND] = millisInDay % 1000; areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true; }
protected synchronized void computeFields() { boolean gregorian = (time >= gregorianCutover); TimeZone zone = getTimeZone(); fields[ZONE_OFFSET] = zone.getRawOffset(); long localTime = time + fields[ZONE_OFFSET]; long day = localTime / (24 * 60 * 60 * 1000L); int millisInDay = (int) (localTime % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } calculateDay(fields, day, gregorian); fields[DST_OFFSET] = zone.getOffset(fields[ERA], fields[YEAR], fields[MONTH], fields[DAY_OF_MONTH], fields[DAY_OF_WEEK], millisInDay) - fields[ZONE_OFFSET]; millisInDay += fields[DST_OFFSET]; if (millisInDay >= 24 * 60 * 60 * 1000) { millisInDay -= 24 * 60 * 60 * 1000; calculateDay(fields, ++day, gregorian); } fields[DAY_OF_WEEK_IN_MONTH] = (fields[DAY_OF_MONTH] + 6) / 7; // which day of the week are we (0..6), relative to getFirstDayOfWeek int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7; fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7; int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7; // Do the Correction: getMinimalDaysInFirstWeek() is always in the // first week. int minDays = getMinimalDaysInFirstWeek(); int firstWeekday = (7 + getWeekDay(fields[YEAR], minDays) - getFirstDayOfWeek()) % 7; if (minDays - firstWeekday < 1) weekOfYear++; fields[WEEK_OF_YEAR] = weekOfYear; int hourOfDay = millisInDay / (60 * 60 * 1000); fields[AM_PM] = (hourOfDay < 12) ? AM : PM; int hour = hourOfDay % 12; fields[HOUR] = (hour == 0) ? 12 : hour; fields[HOUR_OF_DAY] = hourOfDay; millisInDay %= (60 * 60 * 1000); fields[MINUTE] = millisInDay / (60 * 1000); millisInDay %= (60 * 1000); fields[SECOND] = millisInDay / (1000); fields[MILLISECOND] = millisInDay % 1000; areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true; }
7,604
protected synchronized void computeFields() { boolean gregorian = (time >= gregorianCutover); TimeZone zone = getTimeZone(); fields[ZONE_OFFSET] = zone.getRawOffset(); long localTime = time + fields[ZONE_OFFSET]; long day = localTime / (24 * 60 * 60 * 1000L); int millisInDay = (int) (localTime % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } calculateDay(fields, day, gregorian); fields[DST_OFFSET] = zone.getOffset(fields[ERA], fields[YEAR], fields[MONTH], fields[DAY_OF_MONTH], fields[DAY_OF_WEEK], millisInDay) - fields[ZONE_OFFSET]; millisInDay += fields[DST_OFFSET]; if (millisInDay >= 24 * 60 * 60 * 1000) { millisInDay -= 24 * 60 * 60 * 1000; calculateDay(fields, ++day, gregorian); } fields[DAY_OF_WEEK_IN_MONTH] = (fields[DAY_OF_MONTH] + 6) / 7; // which day of the week are we (0..6), relative to getFirstDayOfWeek int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7; fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7; int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7; // Do the Correction: getMinimalDaysInFirstWeek() is always in the // first week. int minDays = getMinimalDaysInFirstWeek(); int firstWeekday = (7 + getWeekDay(fields[YEAR], minDays) - getFirstDayOfWeek()) % 7; if (minDays - firstWeekday < 1) weekOfYear++; fields[WEEK_OF_YEAR] = weekOfYear; int hourOfDay = millisInDay / (60 * 60 * 1000); fields[AM_PM] = (hourOfDay < 12) ? AM : PM; int hour = hourOfDay % 12; fields[HOUR] = (hour == 0) ? 12 : hour; fields[HOUR_OF_DAY] = hourOfDay; millisInDay %= (60 * 60 * 1000); fields[MINUTE] = millisInDay / (60 * 1000); millisInDay %= (60 * 1000); fields[SECOND] = millisInDay / (1000); fields[MILLISECOND] = millisInDay % 1000; areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true; }
protectedsynchronizedvoidcomputeFields(){ booleangregorian=(time>=gregorianCutover); TimeZonezone=getTimeZone(); fields[ZONE_OFFSET]=zone.getRawOffset(); longlocalTime=time+fields[ZONE_OFFSET];longday=localTime/(24*60*60*1000L); intmillisInDay=(int)(localTime%(24*60*60*1000L));if(millisInDay<0){ millisInDay+=(24*60*60*1000); day--; }calculateDay(fields,day,gregorian);fields[DST_OFFSET]=zone.getOffset(fields[ERA],fields[YEAR],fields[MONTH], fields[DAY_OF_MONTH],fields[DAY_OF_WEEK], millisInDay)-fields[ZONE_OFFSET]; millisInDay+=fields[DST_OFFSET];if(millisInDay>=24*60*60*1000){ millisInDay-=24*60*60*1000; calculateDay(fields,++day,gregorian); } fields[DAY_OF_WEEK_IN_MONTH]=(fields[DAY_OF_MONTH]+6)/7; //whichdayoftheweekarewe(0..6),relativetogetFirstDayOfWeek intrelativeWeekday=(7+fields[DAY_OF_WEEK]-getFirstDayOfWeek())%7;fields[WEEK_OF_MONTH]=(fields[DAY_OF_MONTH]-relativeWeekday+12)/7; intweekOfYear=(fields[DAY_OF_YEAR]-relativeWeekday+6)/7; //DotheCorrection:getMinimalDaysInFirstWeek()isalwaysinthe //firstweek. intminDays=getMinimalDaysInFirstWeek();intfirstWeekday=(7+getWeekDay(fields[YEAR],minDays)-getFirstDayOfWeek())%7; if(minDays-firstWeekday<1) weekOfYear++; fields[WEEK_OF_YEAR]=weekOfYear; inthourOfDay=millisInDay/(60*60*1000); fields[AM_PM]=(hourOfDay<12)?AM:PM; inthour=hourOfDay%12; fields[HOUR]=(hour==0)?12:hour; fields[HOUR_OF_DAY]=hourOfDay; millisInDay%=(60*60*1000); fields[MINUTE]=millisInDay/(60*1000); millisInDay%=(60*1000); fields[SECOND]=millisInDay/(1000); fields[MILLISECOND]=millisInDay%1000;areFieldsSet=isSet[ERA]=isSet[YEAR]=isSet[MONTH]=isSet[WEEK_OF_YEAR]=isSet[WEEK_OF_MONTH]=isSet[DAY_OF_MONTH]=isSet[DAY_OF_YEAR]=isSet[DAY_OF_WEEK]=isSet[DAY_OF_WEEK_IN_MONTH]=isSet[AM_PM]=isSet[HOUR]=isSet[HOUR_OF_DAY]=isSet[MINUTE]=isSet[SECOND]=isSet[MILLISECOND]=isSet[ZONE_OFFSET]=isSet[DST_OFFSET]=true; }
7,605
protected synchronized void computeFields() { boolean gregorian = (time >= gregorianCutover); TimeZone zone = getTimeZone(); fields[ZONE_OFFSET] = zone.getRawOffset(); long localTime = time + fields[ZONE_OFFSET]; long day = localTime / (24 * 60 * 60 * 1000L); int millisInDay = (int) (localTime % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } calculateDay(fields, day, gregorian); fields[DST_OFFSET] = zone.getOffset(fields[ERA], fields[YEAR], fields[MONTH], fields[DAY_OF_MONTH], fields[DAY_OF_WEEK], millisInDay) - fields[ZONE_OFFSET]; millisInDay += fields[DST_OFFSET]; if (millisInDay >= 24 * 60 * 60 * 1000) { millisInDay -= 24 * 60 * 60 * 1000; calculateDay(fields, ++day, gregorian); } fields[DAY_OF_WEEK_IN_MONTH] = (fields[DAY_OF_MONTH] + 6) / 7; // which day of the week are we (0..6), relative to getFirstDayOfWeek int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7; fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7; int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7; // Do the Correction: getMinimalDaysInFirstWeek() is always in the // first week. int minDays = getMinimalDaysInFirstWeek(); int firstWeekday = (7 + getWeekDay(fields[YEAR], minDays) - getFirstDayOfWeek()) % 7; if (minDays - firstWeekday < 1) weekOfYear++; fields[WEEK_OF_YEAR] = weekOfYear; int hourOfDay = millisInDay / (60 * 60 * 1000); fields[AM_PM] = (hourOfDay < 12) ? AM : PM; int hour = hourOfDay % 12; fields[HOUR] = (hour == 0) ? 12 : hour; fields[HOUR_OF_DAY] = hourOfDay; millisInDay %= (60 * 60 * 1000); fields[MINUTE] = millisInDay / (60 * 1000); millisInDay %= (60 * 1000); fields[SECOND] = millisInDay / (1000); fields[MILLISECOND] = millisInDay % 1000; areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true; }
protected synchronized void computeFields() { boolean gregorian = (time >= gregorianCutover); TimeZone zone = getTimeZone(); fields[ZONE_OFFSET] = zone.getRawOffset(); long localTime = time + fields[ZONE_OFFSET]; long day = localTime / (24 * 60 * 60 * 1000L); int millisInDay = (int) (localTime % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } calculateDay(fields, day, gregorian); fields[DST_OFFSET] = zone.getOffset(fields[ERA], fields[YEAR], fields[MONTH], fields[DAY_OF_MONTH], fields[DAY_OF_WEEK], millisInDay) - fields[ZONE_OFFSET]; millisInDay += fields[DST_OFFSET]; if (millisInDay >= 24 * 60 * 60 * 1000) { millisInDay -= 24 * 60 * 60 * 1000; calculateDay(fields, ++day, gregorian); } fields[DAY_OF_WEEK_IN_MONTH] = (fields[DAY_OF_MONTH] + 6) / 7; // which day of the week are we (0..6), relative to getFirstDayOfWeek int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7; fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7; int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7; // Do the Correction: getMinimalDaysInFirstWeek() is always in the // first week. int minDays = getMinimalDaysInFirstWeek(); int firstWeekday = (7 + getWeekDay(fields[YEAR], minDays) - getFirstDayOfWeek()) % 7; if (minDays - firstWeekday < 1) weekOfYear++; fields[WEEK_OF_YEAR] = weekOfYear; int hourOfDay = millisInDay / (60 * 60 * 1000); fields[AM_PM] = (hourOfDay < 12) ? AM : PM; int hour = hourOfDay % 12; fields[HOUR] = (hour == 0) ? 12 : hour; fields[HOUR_OF_DAY] = hourOfDay; millisInDay %= (60 * 60 * 1000); fields[MINUTE] = millisInDay / (60 * 1000); millisInDay %= (60 * 1000); fields[SECOND] = millisInDay / (1000); fields[MILLISECOND] = millisInDay % 1000; areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true; }
7,606
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
7,607
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
protectedsynchronizedvoidcomputeTime(){ intera=isSet[ERA]?fields[ERA]:AD; intyear=isSet[YEAR]?fields[YEAR]:1970;if(isLenient()&&isSet[MONTH]){ intmonth=fields[MONTH]; year+=month/12; month%=12; if(month<0) { month+=12; year--; } fields[MONTH]=month; isSet[YEAR]=true; fields[YEAR]=year;} if(era==BC) year=1-year; int[]daysOfYear=getDayOfYear(year); inthour=0; if(isSet[HOUR_OF_DAY]) hour=fields[HOUR_OF_DAY];elseif(isSet[HOUR]){ hour=fields[HOUR]; if(isSet[AM_PM]&&fields[AM_PM]==PM) if(hour!=12)/*notNoon*/ hour+=12; /*Fixtheproblemofthestatusof12:00AM(midnight).*/ if(isSet[AM_PM]&&fields[AM_PM]==AM&&hour==12) hour=0; } intminute=isSet[MINUTE]?fields[MINUTE]:0; intsecond=isSet[SECOND]?fields[SECOND]:0; intmillis=isSet[MILLISECOND]?fields[MILLISECOND]:0; intmillisInDay;if(isLenient()){ //preventoverflow longallMillis=(((hour*60L)+minute)*60L+second)*1000L +millis; daysOfYear[1]+=allMillis/(24*60*60*1000L); millisInDay=(int)(allMillis%(24*60*60*1000L));}else{ if(hour<0||hour>=24||minute<0||minute>59 ||second<0||second>59||millis<0||millis>=1000) thrownewIllegalArgumentException(); millisInDay=(((hour*60)+minute)*60+second)*1000+millis; } time=getLinearTime(year,daysOfYear[0],millisInDay); //Addtherelativedaysaftercalculatingthelineartime,to //getrightbehaviourwhenjumpingoverthegregorianCutover. time+=daysOfYear[1]*(24*60*60*1000L); TimeZonezone=getTimeZone();intrawOffset=isSet[ZONE_OFFSET]?fields[ZONE_OFFSET]:zone.getRawOffset();intday=(int)(time/(24*60*60*1000L));millisInDay=(int)(time%(24*60*60*1000L));if(millisInDay<0){ millisInDay+=(24*60*60*1000); day--;}int[]f=newint[FIELD_COUNT];calculateDay(f,day,time-rawOffset>=gregorianCutover);year=f[YEAR];intmonth=f[MONTH];day=f[DAY_OF_MONTH];intweekday=f[DAY_OF_WEEK];intdstOffset=isSet[DST_OFFSET]?fields[DST_OFFSET]:(zone.getOffset((year<0)?BC:AD, (year<0)?1-year:year, month,day,weekday,millisInDay) -zone.getRawOffset()); time-=rawOffset+dstOffset; isTimeSet=true; }
7,608
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
7,609
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
7,610
public boolean equals(Object o) { if (!(o instanceof GregorianCalendar)) return false; GregorianCalendar cal = (GregorianCalendar) o; return (cal.getTimeInMillis() == getTimeInMillis()); }
public boolean equals(Object o) { if (!(o instanceof GregorianCalendar)) return false; GregorianCalendar cal = (GregorianCalendar) o; return (cal.getTimeInMillis() == getTimeInMillis()); }
7,611
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
7,612
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
7,613
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
7,614
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
7,615
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
7,616
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
public int getActualMaximum(int field) { switch (field) { case WEEK_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); // This is wrong for the year that contains the gregorian change. // I.e it gives the weeks in the julian year or in the gregorian // year in that case. int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int lastDay = isLeapYear(year) ? 366 : 365; int weekday = getWeekDay(year, lastDay); int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; int minimalDays = getMinimalDaysInFirstWeek(); int firstWeekday = getWeekDay(year, minimalDays); /* * Is there a set of days at the beginning of the year, before the * first day of the week, equal to or greater than the minimum number * of days required in the first week? */ if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1) return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */ } case DAY_OF_MONTH: { if (!areFieldsSet || !isSet[MONTH]) complete(); int month = fields[MONTH]; // If you change this, you should also change // SimpleTimeZone.getDaysInMonth(); if (month == FEBRUARY) { if (!isSet[YEAR] || !isSet[ERA]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 29 : 28; } else if (month < AUGUST) return 31 - (month & 1); else return 30 + (month & 1); } case DAY_OF_YEAR: { if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; return isLeapYear(year) ? 366 : 365; } case DAY_OF_WEEK_IN_MONTH: { // This is wrong for the month that contains the gregorian change. int daysInMonth = getActualMaximum(DAY_OF_MONTH); // That's black magic, I know return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7; } case WEEK_OF_MONTH: { int daysInMonth = getActualMaximum(DAY_OF_MONTH); int weekday = (daysInMonth - fields[DAY_OF_MONTH] + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY; return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7; } default: return maximums[field]; } }
7,617
public int getActualMinimum(int field) { if (field == WEEK_OF_YEAR) { int min = getMinimalDaysInFirstWeek(); if (min == 0) return 1; if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int weekday = getWeekDay(year, min); if ((7 + weekday - getFirstDayOfWeek()) % 7 >= min - 1) return 1; return 0; } return minimums[field]; }
public int getActualMinimum(int field) { if (field == WEEK_OF_YEAR) { int min = getMinimalDaysInFirstWeek(); if (min == 0) return 1; if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR]) complete(); int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR]; int weekday = getWeekDay(year, min); if ((7 + weekday - getFirstDayOfWeek()) % 7 >= min - 1) return 1; return 0; } return minimums[field]; }
7,618
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
privateint[]getDayOfYear(intyear){if(isSet[MONTH]){ intdayOfYear; if(fields[MONTH]>FEBRUARY) { //ThemonthsafterFebruaryareregular: //9isanoffsetfoundbytryanderror. dayOfYear=(fields[MONTH]*(31+30+31+30+31)-9)/5; if(isLeapYear(year)) dayOfYear++; } else dayOfYear=31*fields[MONTH]; if(isSet[DAY_OF_MONTH]) { returnnewint[] { dayOfYear+fields[DAY_OF_MONTH],0}; } if(isSet[WEEK_OF_MONTH]&&isSet[DAY_OF_WEEK]) { //theweekdayofthefirstdayinthatmonthis: intweekday=getWeekDay(year,++dayOfYear); returnnewint[] { dayOfYear, //thedayofweekinthefirstweek //(weeksstartingonsunday)is: fields[DAY_OF_WEEK]-weekday+ //Nowjumptotherightweekandcorrectthepossible //errormadebyassumingsundayisthefirstweekday. 7*(fields[WEEK_OF_MONTH] +(fields[DAY_OF_WEEK]<getFirstDayOfWeek()?0:-1) +(weekday<getFirstDayOfWeek()?-1:0))}; } if(isSet[DAY_OF_WEEK]&&isSet[DAY_OF_WEEK_IN_MONTH]) { //theweekdayofthefirstdayinthatmonthis: intweekday=getWeekDay(year,++dayOfYear); returnnewint[]{ dayOfYear, fields[DAY_OF_WEEK]-weekday+ 7*(fields[DAY_OF_WEEK_IN_MONTH] +(fields[DAY_OF_WEEK]<weekday?0:-1))}; } } //MONTH+somethingdidnotsucceed.if(isSet[DAY_OF_YEAR]){ returnnewint[]{0,fields[DAY_OF_YEAR]}; }if(isSet[DAY_OF_WEEK]&&isSet[WEEK_OF_YEAR]){ intdayOfYear=getMinimalDaysInFirstWeek(); //theweekdayoftheday,thatbeginsthefirstweek //inthatyearis: intweekday=getWeekDay(year,dayOfYear); returnnewint[]{ dayOfYear, //thedayofweekinthefirstweek //(weeksstartingonsunday)is: fields[DAY_OF_WEEK]-weekday //Nowjumptotherightweekandcorrectthepossible //errormadebyassumingsundayisthefirstweekday. +7*(fields[WEEK_OF_YEAR] +(fields[DAY_OF_WEEK]<getFirstDayOfWeek()?0:-1) +(weekday<getFirstDayOfWeek()?-1:0))}; } //AslastresortreturnJan,1st.returnnewint[]{1,0}; }
7,619
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
7,620
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
7,621
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
7,622
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
7,623
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
7,624
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
7,625
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
private int[] getDayOfYear(int year) { if (isSet[MONTH]) { int dayOfYear; if (fields[MONTH] > FEBRUARY) { // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; if (isLeapYear(year)) dayOfYear++; } else dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) { return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0}; } if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. 7 * (fields[WEEK_OF_MONTH] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] { dayOfYear, fields[DAY_OF_WEEK] - weekday + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) { return new int[] {0, fields[DAY_OF_YEAR]}; } if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); return new int[] { dayOfYear, // the day of week in the first week // (weeks starting on sunday) is: fields[DAY_OF_WEEK] - weekday // Now jump to the right week and correct the possible // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_YEAR] + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) + (weekday < getFirstDayOfWeek()? -1 : 0))}; } // As last resort return Jan, 1st. return new int[] {1, 0}; }
7,626