/** * Returns a {@link String} representation of this date. * * @return An {@link Iso8601Date}-formatted string, or the value of {@link #LAZY_NOW_LABEL} if this is a "lazy now" instance. */ @Override public String toString() { return doSetTimeNextQuery ? LAZY_NOW_LABEL : super.toString(); }
/** * Returns a {@link String} representation of this date. * * @return An {@link Iso8601Date}-formatted string, or the value of {@link #LAZY_NOW_LABEL} if this is a "lazy now" instance. */ @Override public String toString() { return doSetTimeNextQuery ? LAZY_NOW_LABEL : super.toString(); }
/** * Returns a {@link String} representation of this date. * @return An {@link Iso8601Date}-formatted string, or the value of {@link #LAZY_NOW_LABEL} if this is a "lazy now" instance. */ @Override public String toString() { return doSetTimeNextQuery ? LAZY_NOW_LABEL : super.toString(); }
/** Formats date & time */ public String format(final Iso8601Date value) { return value.toString(); }
/** Formats date & time */ public String format(final Iso8601Date value) { return value.toString(); }
/** Formats date & time */ public String format(final Iso8601Date value) { return value.toString(); }
public RelativeIso8601Date(final String dateStr) { /** * We must pass a date parsable {@link Iso8601Date#Iso8601Date(String)}; we will never actually read the passed value, so it doesn't * matter what it is. */ super(LAZY_NOW_LABEL.equals(dateStr) ? new Iso8601Date(new Date()).toString() : dateStr); doSetTimeNextQuery = LAZY_NOW_LABEL.equals(dateStr); }
public RelativeIso8601Date(final String dateStr) { /** * We must pass a date parsable {@link Iso8601Date#Iso8601Date(String)}; we will never actually read the passed value, so it doesn't * matter what it is. */ super(LAZY_NOW_LABEL.equals(dateStr) ? new Iso8601Date(new Date()).toString() : dateStr); doSetTimeNextQuery = LAZY_NOW_LABEL.equals(dateStr); }
public RelativeIso8601Date(final String dateStr) { /** * We must pass a date parsable {@link Iso8601Date#Iso8601Date(String)}; we will never actually read the passed value, so it doesn't * matter what it is. */ super(LAZY_NOW_LABEL.equals(dateStr) ? new Iso8601Date(new Date()).toString() : dateStr); doSetTimeNextQuery = LAZY_NOW_LABEL.equals(dateStr); }
/** * Create the list of headers that will be added to the SAMFileHeader for a library with the given sampleBarcodes (or * the entire run if sampleBarcodes == NULL). Note that any value that is null will NOT be added via buildSamFileWriter * but is placed in the map in order to be able to query the tags that we automatically add. * * @param barcodes The list of sampleBarcodes that uniquely identify the read group we are building parameters for * @return A Map of ReadGroupHeaderTags -> Values */ private Map<String, String> buildSamHeaderParameters(final List<String> barcodes) { final Map<String, String> params = new LinkedHashMap<>(); String platformUnit = RUN_BARCODE + "." + LANE; if (barcodes != null) { final String barcodeString = IlluminaUtil.barcodeSeqsToString(barcodes); platformUnit += "." + barcodeString; if (INCLUDE_BC_IN_RG_TAG) { params.put("BC", barcodeString); } } if (PLATFORM != null) { params.put(SAMReadGroupRecord.PLATFORM_TAG, PLATFORM); } params.put(SAMReadGroupRecord.PLATFORM_UNIT_TAG, platformUnit); if (SEQUENCING_CENTER != null) { params.put(SAMReadGroupRecord.SEQUENCING_CENTER_TAG, SEQUENCING_CENTER); } params.put(SAMReadGroupRecord.DATE_RUN_PRODUCED_TAG, RUN_START_DATE == null ? null : new Iso8601Date(RUN_START_DATE).toString()); return params; }
/** * Create the list of headers that will be added to the SAMFileHeader for a library with the given sampleBarcodes (or * the entire run if sampleBarcodes == NULL). Note that any value that is null will NOT be added via buildSamFileWriter * but is placed in the map in order to be able to query the tags that we automatically add. * * @param barcodes The list of sampleBarcodes that uniquely identify the read group we are building parameters for * @return A Map of ReadGroupHeaderTags -> Values */ private Map<String, String> buildSamHeaderParameters(final List<String> barcodes) { final Map<String, String> params = new LinkedHashMap<>(); String platformUnit = RUN_BARCODE + "." + LANE; if (barcodes != null) { final String barcodeString = IlluminaUtil.barcodeSeqsToString(barcodes); platformUnit += "." + barcodeString; if (INCLUDE_BC_IN_RG_TAG) { params.put("BC", barcodeString); } } if (PLATFORM != null) { params.put(SAMReadGroupRecord.PLATFORM_TAG, PLATFORM); } params.put(SAMReadGroupRecord.PLATFORM_UNIT_TAG, platformUnit); if (SEQUENCING_CENTER != null) { params.put(SAMReadGroupRecord.SEQUENCING_CENTER_TAG, SEQUENCING_CENTER); } params.put(SAMReadGroupRecord.DATE_RUN_PRODUCED_TAG, RUN_START_DATE == null ? null : new Iso8601Date(RUN_START_DATE).toString()); return params; }
@Test public void testBasic() { final String dateStr = "2008-12-15"; Iso8601Date first = new Iso8601Date(dateStr); String firstFormatted = first.toString(); Iso8601Date second = new Iso8601Date(firstFormatted); Assert.assertEquals(first, second); String secondFormatted = second.toString(); Assert.assertEquals(firstFormatted, secondFormatted); }
@Test public void testNonLazyInstance() { final long time = new Iso8601Date(new Date(System.currentTimeMillis())).getTime(); // ISO strips off milliseconds // Test both constructor methods final List<RelativeIso8601Date> testDates = Arrays.<RelativeIso8601Date>asList( new RelativeIso8601Date(new Date(time)), new RelativeIso8601Date(new Iso8601Date(new Date(time)).toString()) ); for (final RelativeIso8601Date nonLazy : testDates) { Assert.assertFalse(nonLazy.toString().equals(RelativeIso8601Date.LAZY_NOW_LABEL)); Assert.assertEquals((double) nonLazy.getTime(), (double) time, DELTA_FOR_TIME); // Assert no exception thrown; this should be valid, because toString return an iso-looking date. new RelativeIso8601Date(nonLazy.toString()); } }
@Test public void equalityTest() { final String s = new Iso8601Date(new Date(12345)).toString(); final Iso8601Date iso8601Date = new Iso8601Date(s); final RelativeIso8601Date relativeIso8601Date = new RelativeIso8601Date(s); Assert.assertEquals(relativeIso8601Date.getTime(), iso8601Date.getTime(), DELTA_FOR_TIME); } }