Please help me on this problem

public class DBAdapter {
     private Calendar calendar;
     public DBAdapter(
               Context context,
               String harborCode,
               Calendar calendar)
                        this.calendar = calendar;
     public Calendar     getCalendar()     { return this.calendar; }
     public int     getDate()     { return this.calendar.get(Calendar.DATE); }
     private void replaceMonthOnline() throws IOException {
           * WHY DOES IT CHANGE THIS.CALENDAR ?!?
          Calendar tmpCalendar = getCalendar();
          int monthMax = tmpCalendar.getActualMaximum(Calendar.DATE);
          int monthMin = tmpCalendar.getActualMinimum(Calendar.DATE);
          tmpCalendar.set(Calendar.DATE, monthMin); // <---- THE PROBLEM IS EVIDENT FROM HERE ON.
(...)And this changes the date also in this.calendar.
I want tmpCalendar to be changed without changing the class Calendar, too. How do I do this?
I believe this has something to do with the pass-by-reference design. But how do I achieve what I want in this case, another Calendar with the same values, and that changing one won't change the other?
Thank you.
Edited by: 801999 on Oct 12, 2010 8:29 PM
Edited by: 801999 on Oct 12, 2010 8:29 PM

Thanks everyone.
DrClap, that's exactly what I needed. I was trying something a little different, but was getting errors from the compiler (static references). Your solution worked perfectly. :-)
Pinto, thanks for the correction. That's what I mean. I'm here at almost 2 AM, sitting in front of the computer! :-)
RAM, yeah, I could try getting a new instance and modifying it later. But DrClap's is definitely the perfect, clean and finished solution. Also, I wasn't aware of all the innerworks of the Calendar class yet. So seeing how I could get the time of one and put it into another helped me even more.

Similar Messages

Maybe you are looking for

  • Good Software for Organization

    Does anyone know of any good software to download on the MacBook to Organize one's schedule? I want to something with lots of colors, multitasking capabilities, and a 3D visual display also if possible.

  • How to put the garageband songs

    i have currently some songs with the ending.band all these are songs but i want to put them into the ipad of garageband how do i do that? does it allow me to do that anyway?

  • Dvt:map Selection Iterator

    This is a question of urgency. It is holding up a deliverable. The dvt:mapPointTheme selectionListener property does not seem to fill the Iterator with the selected data point information any longer. This code used to work in TP4. Here is the .jspx c

  • New iMac wifi slow on Airport network, not on Fastweb

    I just replaced our old iMac (Intel Core 2 Duo, 2.33 GHz, Airport Extreme Card 802.11 a/b/g/n - OS 10.6.8) a new refurbished iMac 27-inch (late 2012) (OS 10.8.4).  The new computer works great, except with wifi - it is painfully slow on our Airport n

  • Calling standard printer driver program RVADOR01 from ALV report

    I have ALV report (Sales order documents) and one of columns in report is icon type with print preview link (hotspot). When user press icon, I would like to call standard print program RVADOR01 (actually we have custom Z_RVADOR01 and custom smartform