I'm up to my wits end on this annoying problem. Basically couldn't fix this for a long time.
java.util.Calendar calendar_now = java.util.Calendar.getInstance();
java.util.Calendar calendar_entry = java.util.Calendar.getInstance();
java.util.Date dt = new Date();
java.text.SimpleDateFormat formatter;
try{
// if(this.Time.length() == 0) {this.Time = "00:00";}
//this.Time = "00:00";
// System.out.println("*" + this.Time + "*");
if((this.Time.substring(this.Time.length() - 2) == "am")||(this.Time.substring(this.Time.length() - 2) == "pm"))
{
formatter = new SimpleDateFormat("yyyy E MMM d H:mmaa z",Locale.US);
dt = (Date)formatter.parse(calendar_now.get(java.util.Calendar.YEAR) + " " + this.Date + " " + this.Time + " EST");
//calendar_entry.setTimeZone(java.util.TimeZone.getTimeZone("America/New_York"));
}
calendar_entry.setTime(dt);
if (calendar_entry.get(java.util.Calendar.MONTH) < calendar_now.get(java.util.Calendar.MONTH)){
calendar_entry.set(java.util.Calendar.YEAR,calendar_now.get(java.util.Calendar.YEAR) + 1);
}
else{
calendar_entry.set(java.util.Calendar.YEAR,calendar_now.get(java.util.Calendar.YEAR));
}
// calendar_entry.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
System.out.println(calendar_now.get(java.util.Calendar.YEAR) + " " + this.Date + " " + this.Time + " EST");
System.out.println(dt.toString());
System.out.println(calendar_entry);
This produces:
2010 Fri Oct 1 10:00am EST Thu Oct 01 10:00:00 SGT 1970 java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=true,lenient=true,zone=sun.uti l.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],fi rstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2010,MONTH=9,WEEK_OF_YEAR=40,WEEK_OF_MONTH=1,DAY_ OF_MONTH=1,DAY_OF_YEAR=274,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=2,HOUR_OF_DAY=2,MINUTE= 30,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]
Question is... WHY?