java.text.SimpleDateFormat#getTimeZone ( )源码实例Demo

下面列出了java.text.SimpleDateFormat#getTimeZone ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openemm   文件: FormDateTime.java
public void set(Date value, SimpleDateFormat dateFormat) {
    if (value == null) {
        date.setDate(null);
        time.setTime(null);
    } else {
        TimeZone timezone = dateFormat.getTimeZone();
        date.set(value, dateFormat);
        time.set(value, timezone.toZoneId());
    }
}
 
源代码2 项目: ranger   文件: RangerScriptExecutionContext.java
private Date getAsDate(String value, SimpleDateFormat df) {
	Date ret = null;

	TimeZone savedTimeZone = df.getTimeZone();
	try {
		ret = df.parse(value);
	} catch (ParseException exception) {
		// Ignore
	} finally {
		df.setTimeZone(savedTimeZone);
	}

	return ret;
}
 
源代码3 项目: oodt   文件: DateConvert.java
/**
	Format the given date and return the resulting string in ISO 8601 format.

	The format is as follows: "yyyy-MM-dd'T'HH:mm:ss.SSS[Z|[+|-]HH:mm]".

	@param inputDate The date to be converted into string format.
	@return The formatted date/time string.
*/
public static String isoFormat(Date inputDate) {

	// Setup the date format and convert the given date.
	SimpleDateFormat dateFormat = new SimpleDateFormat(ISO_FORMAT);
	String dateString = dateFormat.format(inputDate);

	// Determine the time zone and concatenate the time zone designator
	// onto the formatted date/time string.
	TimeZone tz = dateFormat.getTimeZone();
	String tzName = tz.getDisplayName();
	if (tzName.equals("Greenwich Mean Time") && !TimeZone.getDefault().inDaylightTime( inputDate )) {
		dateString = dateString.concat("Z");
	}
	else {
		// Determine the hour offset. Add an hour if daylight savings
		// is in effect.
		long tzOffsetMS = tz.getRawOffset();
		long tzOffsetHH = tzOffsetMS / MS_IN_HOUR;
		if (tz.inDaylightTime(inputDate)) {
			tzOffsetHH = tzOffsetHH + 1;
		}
		String hourString = String.valueOf(Math.abs(tzOffsetHH));
		if (hourString.length() == 1) {
			hourString = "0" + hourString;
		}

		// Determine the minute offset.
		long tzOffsetMMMS = tzOffsetMS % MS_IN_HOUR;
		long tzOffsetMM = 0;
		if (tzOffsetMMMS != 0) {
			tzOffsetMM = tzOffsetMMMS / MS_IN_MINUTE;
		}
		String minuteString = String.valueOf(tzOffsetMM);
		if (minuteString.length() == 1) {
			minuteString = "0" + minuteString;
		}

		// Determine the sign of the offset.
		String sign = "+";
		if (String.valueOf(tzOffsetMS).contains("-")) {
			sign = "-";
		}

		dateString = dateString.concat(sign + hourString + ":" + minuteString);
	}

	return(dateString);
}
 
源代码4 项目: NexusDialog   文件: TimePickerController.java
/**
 * Constructs a new instance of a time picker field.
 *
 * @param ctx               the Android context
 * @param name              the name of the field
 * @param labelText         the label to display beside the field. Set to {@code null} to not show a label.
 * @param validators        contains the validations to process on the field
 * @param displayFormat     the format of the time to show in the text box when a time is set
 * @param is24HourView      the format of time picker dialog should be 24 hour format or not
 */
public TimePickerController(Context ctx, String name, String labelText,  Set<InputValidator> validators, SimpleDateFormat displayFormat, boolean is24HourView) {
    super(ctx, name, labelText, validators);
    this.displayFormat = displayFormat;
    this.timeZone = displayFormat.getTimeZone();
    this.is24HourView = is24HourView;
}
 
源代码5 项目: NexusDialog   文件: TimePickerController.java
/**
 * Constructs a new instance of a time picker field.
 *
 * @param ctx               the Android context
 * @param name              the name of the field
 * @param labelText         the label to display beside the field. Set to {@code null} to not show a label.
 * @param isRequired        indicates if the field is required or not
 * @param displayFormat     the format of the time to show in the text box when a time is set
 * @param is24HourView      the format of time picker dialog should be 24 hour format or not
 */
public TimePickerController(Context ctx, String name, String labelText, boolean isRequired, SimpleDateFormat displayFormat, boolean is24HourView) {
    super(ctx, name, labelText, isRequired);
    this.displayFormat = displayFormat;
    this.timeZone = displayFormat.getTimeZone();
    this.is24HourView = is24HourView;
}
 
源代码6 项目: NexusDialog   文件: DatePickerController.java
/**
 * Constructs a new instance of a date picker field.
 *
 * @param ctx               the Android context
 * @param name              the name of the field
 * @param labelText         the label to display beside the field. Set to {@code null} to not show a label.
 * @param validators        contains the validations to process on the field
 * @param displayFormat     the format of the date to show in the text box when a date is set
 */
public DatePickerController(Context ctx, String name, String labelText, Set<InputValidator> validators, SimpleDateFormat displayFormat) {
    super(ctx, name, labelText, validators);
    this.displayFormat = displayFormat;
    this.timeZone = displayFormat.getTimeZone();
}
 
源代码7 项目: NexusDialog   文件: DatePickerController.java
/**
 * Constructs a new instance of a date picker field.
 *
 * @param ctx               the Android context
 * @param name              the name of the field
 * @param labelText         the label to display beside the field. Set to {@code null} to not show a label.
 * @param isRequired        indicates if the field is required or not
 * @param displayFormat     the format of the date to show in the text box when a date is set
 */
public DatePickerController(Context ctx, String name, String labelText, boolean isRequired, SimpleDateFormat displayFormat) {
    super(ctx, name, labelText, isRequired);
    this.displayFormat = displayFormat;
    this.timeZone = displayFormat.getTimeZone();
}