Java Code Examples for java.text.SimpleDateFormat#getTimeZone()
The following examples show how to use
java.text.SimpleDateFormat#getTimeZone() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FormDateTime.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
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()); } }
Example 2
Source File: RangerScriptExecutionContext.java From ranger with Apache License 2.0 | 5 votes |
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; }
Example 3
Source File: DateConvert.java From oodt with Apache License 2.0 | 4 votes |
/** 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); }
Example 4
Source File: TimePickerController.java From NexusDialog with Apache License 2.0 | 3 votes |
/** * 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; }
Example 5
Source File: TimePickerController.java From NexusDialog with Apache License 2.0 | 3 votes |
/** * 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; }
Example 6
Source File: DatePickerController.java From NexusDialog with Apache License 2.0 | 2 votes |
/** * 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(); }
Example 7
Source File: DatePickerController.java From NexusDialog with Apache License 2.0 | 2 votes |
/** * 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(); }