View | Details | Raw Unified | Return to bug 342086 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/tasks/core/externalization/DelegatingTaskExternalizer.java (-8 / +7 lines)
Lines 53-61 Link Here
53
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
53
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
54
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
54
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
55
import org.eclipse.mylyn.tasks.core.ITask;
55
import org.eclipse.mylyn.tasks.core.ITask;
56
import org.eclipse.mylyn.tasks.core.TaskRepository;
57
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
56
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
58
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
57
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
58
import org.eclipse.mylyn.tasks.core.TaskRepository;
59
import org.w3c.dom.Document;
59
import org.w3c.dom.Document;
60
import org.w3c.dom.Element;
60
import org.w3c.dom.Element;
61
import org.w3c.dom.Node;
61
import org.w3c.dom.Node;
Lines 75-81 Link Here
75
75
76
	static final String DEFAULT_PRIORITY = PriorityLevel.P3.toString();
76
	static final String DEFAULT_PRIORITY = PriorityLevel.P3.toString();
77
77
78
	static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.S z"; //$NON-NLS-1$
78
	static final String OUT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.S Z"; //$NON-NLS-1$
79
80
	static final String IN_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.S z"; //$NON-NLS-1$
79
81
80
	static final String KEY_NOTIFIED_INCOMING = "NotifiedIncoming"; //$NON-NLS-1$
82
	static final String KEY_NOTIFIED_INCOMING = "NotifiedIncoming"; //$NON-NLS-1$
81
83
Lines 347-354 Link Here
347
		if (date == null) {
349
		if (date == null) {
348
			return ""; //$NON-NLS-1$
350
			return ""; //$NON-NLS-1$
349
		}
351
		}
350
		String f = DATE_FORMAT;
352
		SimpleDateFormat format = new SimpleDateFormat(OUT_DATE_FORMAT, Locale.ENGLISH);
351
		SimpleDateFormat format = new SimpleDateFormat(f, Locale.ENGLISH);
352
		return format.format(date);
353
		return format.format(date);
353
	}
354
	}
354
355
Lines 356-363 Link Here
356
		if (date == null) {
357
		if (date == null) {
357
			return ""; //$NON-NLS-1$
358
			return ""; //$NON-NLS-1$
358
		}
359
		}
359
		String f = DATE_FORMAT;
360
		SimpleDateFormat format = new SimpleDateFormat(OUT_DATE_FORMAT, Locale.ENGLISH);
360
		SimpleDateFormat format = new SimpleDateFormat(f, Locale.ENGLISH);
361
		return format.format(date.getTime());
361
		return format.format(date.getTime());
362
	}
362
	}
363
363
Lines 638-645 Link Here
638
		if ("".equals(dateString)) { //$NON-NLS-1$
638
		if ("".equals(dateString)) { //$NON-NLS-1$
639
			return null;
639
			return null;
640
		}
640
		}
641
		String formatString = DATE_FORMAT;
641
		SimpleDateFormat format = new SimpleDateFormat(IN_DATE_FORMAT, Locale.ENGLISH);
642
		SimpleDateFormat format = new SimpleDateFormat(formatString, Locale.ENGLISH);
643
		try {
642
		try {
644
			date = format.parse(dateString);
643
			date = format.parse(dateString);
645
		} catch (ParseException e) {
644
		} catch (ParseException e) {
(-)src/org/eclipse/mylyn/tasks/tests/TaskListExternalizationTest.java (+24 lines)
Lines 17-22 Link Here
17
import java.util.HashSet;
17
import java.util.HashSet;
18
import java.util.Iterator;
18
import java.util.Iterator;
19
import java.util.Set;
19
import java.util.Set;
20
import java.util.TimeZone;
20
21
21
import junit.framework.TestCase;
22
import junit.framework.TestCase;
22
23
Lines 583-588 Link Here
583
		assertEquals(task.getScheduledForDate(), readTask.getScheduledForDate());
584
		assertEquals(task.getScheduledForDate(), readTask.getScheduledForDate());
584
	}
585
	}
585
586
587
	// test case for bug 342086
588
	public void testDatesTimeZone() throws Exception {
589
		TaskTestUtil.resetTaskListAndRepositories();
590
591
		TimeZone.setDefault(TimeZone.getTimeZone("PRC"));
592
		AbstractTask task = new LocalTask("1", "task 1");
593
		Date creationDate = new Date();
594
		task.setCreationDate(creationDate);
595
		TasksUiPlugin.getTaskList().addTask(task);
596
		assertEquals(1, TasksUiPlugin.getTaskList().getAllTasks().size());
597
598
		TaskTestUtil.saveNow();
599
		TimeZone.setDefault(TimeZone.getTimeZone("CST"));
600
		TaskTestUtil.resetTaskList();
601
		TasksUiPlugin.getDefault().initializeDataSources();
602
603
		assertEquals(1, TasksUiPlugin.getTaskList().getAllTasks().size());
604
		Collection<ITask> readList = TasksUiPlugin.getTaskList().getDefaultCategory().getChildren();
605
		ITask readTask = readList.iterator().next();
606
		assertTrue(readTask.getSummary().equals("task 1"));
607
		assertTrue(readTask.getCreationDate().compareTo(creationDate) == 0);
608
	}
609
586
	// Task retention when connector missing upon startup
610
	// Task retention when connector missing upon startup
587
	public void testOrphanedTasks() throws Exception {
611
	public void testOrphanedTasks() throws Exception {
588
		// make some tasks
612
		// make some tasks

Return to bug 342086