public Date parse( String input ) throws ParseException { format.set2DigitYearStart( Y2K_START_DATE ); return format.parse( input ); }
dateParser = new SimpleDateFormat(format, Locale.US); dateParser.setTimeZone(TimeZone.getTimeZone("GMT")); dateParser.set2DigitYearStart(startDate); } else { dateParser.applyPattern(format);
private void validateSdfFormatFdpParseEquality(final String format, final Locale locale, final TimeZone tz, final DateParser fdp, final Date in, final int year, final Date cs) throws ParseException { final SimpleDateFormat sdf = new SimpleDateFormat(format, locale); sdf.setTimeZone(tz); if (format.equals(SHORT_FORMAT)) { sdf.set2DigitYearStart( cs ); } final String fmt = sdf.format(in); try { final Date out = fdp.parse(fmt); assertEquals(locale.toString()+" "+in+" "+ format+ " "+tz.getID(), in, out); } catch (final ParseException pe) { if (year >= 1868 || !locale.getCountry().equals("JP")) {// LANG-978 throw pe; } } }
dateParser.set2DigitYearStart(startDate);
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { ObjectInputStream.GetField fields = stream.readFields(); int version = fields.get("serialVersionOnStream", 0); Date date; if (version > 0) { date = (Date) fields.get("defaultCenturyStart", new Date()); } else { date = new Date(); } set2DigitYearStart(date); formatData = (DateFormatSymbols) fields.get("formatData", null); pattern = (String) fields.get("pattern", ""); } }
private void validateSdfFormatFdpParseEquality(final String format, final Locale locale, final TimeZone tz, final DateParser fdp, final Date in, final int year, final Date cs) throws ParseException { final SimpleDateFormat sdf = new SimpleDateFormat(format, locale); sdf.setTimeZone(tz); if (format.equals(SHORT_FORMAT)) { sdf.set2DigitYearStart( cs ); } final String fmt = sdf.format(in); try { final Date out = fdp.parse(fmt); assertEquals(locale.toString()+" "+in+" "+ format+ " "+tz.getID(), in, out); } catch (final ParseException pe) { if (year >= 1868 || !locale.getCountry().equals("JP")) {// LANG-978 throw pe; } } }
localSimpleDateFormat.get().set2DigitYearStart(startDate);
private static void update50YearWindowIfNeeded() { // Avoid class synchronization long next = sNext50YearWindowChange; if (next < System.currentTimeMillis()) { // Next check in one day next += DateUtil.DAY; sNext50YearWindowChange = next; Date startDate = new Date(next - (50l * DateUtil.CALENDAR_YEAR)); //System.out.println("next test: " + new Date(next) + ", 50 year start: " + startDate); synchronized (HTTP_RFC850_FORMAT) { HTTP_RFC850_FORMAT.set2DigitYearStart(startDate); } synchronized (HTTP_ASCTIME_FORMAT) { HTTP_ASCTIME_FORMAT.set2DigitYearStart(startDate); } } }
SimpleDateFormat sdf = new SimpleDateFormat("yy/MM/dd", Locale.US); Calendar cal = Calendar.getInstance(Locale.US); cal.set(1900, 0, 1); sdf.set2DigitYearStart(cal.getTime()); System.out.println(sdf.parse("16/07/23"));
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yy"); String aDate = "03/17/40"; Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(Calendar.YEAR, 2000); dateFormat.set2DigitYearStart(cal.getTime()); System.out.println(dateFormat.get2DigitYearStart()); System.out.println(dateFormat.parse(aDate));
dateParser.set2DigitYearStart(localStartDate); final ParsePosition pos = new ParsePosition(0); final Date result = dateParser.parse(v, pos);
dateParser.set2DigitYearStart(startDate);
/** * Sets the 100-year period 2-digit years will be interpreted as being in * to begin on the date the user specifies. * @param startDate During parsing, two digit years will be placed in the range * <code>startDate</code> to <code>startDate + 100 years</code>. * @stable ICU 2.0 */ public void set2DigitYearStart(Date startDate) { ((java.text.SimpleDateFormat)dateFormat).set2DigitYearStart(startDate); }
/** * Sets the 100-year period 2-digit years will be interpreted as being in * to begin on the date the user specifies. * @param startDate During parsing, two digit years will be placed in the range * <code>startDate</code> to <code>startDate + 100 years</code>. * @stable ICU 2.0 */ public void set2DigitYearStart(Date startDate) { ((java.text.SimpleDateFormat)dateFormat).set2DigitYearStart(startDate); }
public Date parse( String input ) throws ParseException { format.set2DigitYearStart( Y2K_START_DATE ); return format.parse( input ); }
/** * {@inheritDoc} * * @deprecated as it is not considered to be thread safe. */ @Deprecated @Override public void set2DigitYearStart( Date startDate ) { super.set2DigitYearStart( startDate ); }
Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2000); SimpleDateFormat inFormat = new SimpleDateFormat("dd/MM/yy"); inFormat.set2DigitYearStart(cal.getTime()); SimpleDateFormat outFormat = new SimpleDateFormat("MM/dd/yyyy"); try { // Old Date is 10/12/03 String value = outFormat.format(inFormat.parse("10/12/03")); System.out.println(value); } catch (ParseException e) { e.printStackTrace(); }
public void set2DigitYearStart(Date date) { getDateFormat(_format).set2DigitYearStart(date); } }
SimpleDateFormat format = new SimpleDateFormat( "dd.MM.yyyy" ); SimpleDateFormat editFormat = new SimpleDateFormat( "dd.MM.yy" ); final Date startDate = new Date( 0 );//01.01.1970 instance.setTime(startDate); editFormat.set2DigitYearStart( instance.getTime() ); DefaultFormatterFactory factory = new DefaultFormatterFactory( new DatePickerFormatter(new DateFormat[] {format}), new DatePickerFormatter(new DateFormat[] {format}), new DatePickerFormatter(new DateFormat[] {editFormat}) ); picker.getEditor().setFormatterFactory(factory);
synchronized SimpleDateFormat getDateFormatter(Integer centuryDigit) { if (centuryDigit == null) return getDateFormatter(); else { Date d = getStartDateForCentury(centuryDigit.intValue()); getDateFormatter(); dateFormatter_.set2DigitYearStart(d); return dateFormatter_; } }