Code example for Time

Methods: formatparse3339switchTimezone

	 * @param dateText the textview which will GET the parsed datestamp set as text 
	 * @param timeText the textview which will GET the parsed timestamp set as text 
	 * @param datetimeStr string in pre-determined format of the datetime to parse 
	public static void setParsedDateTime3999(TextView dateText, TextView timeText, String datetimeStr) {
	    Time readTime = new Time();
	    try { 
			if(readTime.parse3339(datetimeStr)) {  //str was saved out using RFC3339 format, so needs to be read in as such
			    readTime.switchTimezone("Asia/Tokyo");  //parse3339() automatically converts read in times to UTC.  We need to change it back to the default timezone of the handset (JST in this example)
		} catch (TimeFormatException e) {
			//in the case of an un-parse-able datetime str, we will just display the str as is instead of trying to prettify it 
			ClLog.e("setParsedDateTime3999():", "created timestamp could not be parsed; skipping"); 
			ClLog.e("setParsedDateTime3999():", e);
Experience pair programming with AI  Get Codota for Java