@Nonnull public HCTime setAsDate (@Nonnegative final int nYear, @Nonnegative final int nMonth, @Nonnegative final int nDay) { m_sDatetime = StringHelper.getLeadingZero (nYear, LENGTH_YEAR) + "-" + StringHelper.getLeadingZero (nMonth, LENGTH_MONTH) + "-" + StringHelper.getLeadingZero (nDay, LENGTH_DAY); return this; }
@Nonnull public HCTime setAsWeekInYear (@Nonnegative final int nYear, @Nonnegative final int nWeekInYear) { m_sDatetime = StringHelper.getLeadingZero (nYear, LENGTH_YEAR) + "-W" + StringHelper.getLeadingZero (nWeekInYear, LENGTH_WEEKINYEAR); return this; }
@Nonnull public HCTime setAsMonth (@Nonnegative final int nYear, @Nonnegative final int nMonth) { m_sDatetime = StringHelper.getLeadingZero (nYear, LENGTH_YEAR) + "-" + StringHelper.getLeadingZero (nMonth, LENGTH_MONTH); return this; }
@Nonnull public HCTime setAsTime (@Nonnegative final int nHour, @Nonnegative final int nMinute) { m_sDatetime = StringHelper.getLeadingZero (nHour, LENGTH_HOUR) + ":" + StringHelper.getLeadingZero (nMinute, LENGTH_MIN); return this; }
@Nonnull public HCTime setAsTime (@Nonnegative final int nHour, @Nonnegative final int nMinute, @Nonnegative final int nSecond) { m_sDatetime = StringHelper.getLeadingZero (nHour, LENGTH_HOUR) + ":" + StringHelper.getLeadingZero (nMinute, LENGTH_MIN) + ":" + StringHelper.getLeadingZero (nSecond, LENGTH_SEC); return this; }
@Nonnull public HCTime setAsYear (@Nonnegative final int nYear) { m_sDatetime = StringHelper.getLeadingZero (nYear, LENGTH_YEAR); return this; }
@Nonnull public HCTime setAsYearlessDate (@Nonnegative final int nMonth, @Nonnegative final int nDay) { m_sDatetime = StringHelper.getLeadingZero (nMonth, LENGTH_MONTH) + "-" + StringHelper.getLeadingZero (nDay, LENGTH_DAY); return this; }
@Nonnull private File _getUniqueBackupFile (final String sFilename) { long nIndex = 0; File aBackupFile; do { aBackupFile = new File (sFilename + '.' + StringHelper.getLeadingZero (nIndex, 7)); nIndex++; } while (aBackupFile.exists ()); return aBackupFile; }
@Nonnull public HCTime setAsTime (@Nonnegative final int nHour, @Nonnegative final int nMinute, @Nonnegative final int nSecond, @Nonnegative final int nMilliSeconds) { m_sDatetime = StringHelper.getLeadingZero (nHour, LENGTH_HOUR) + ":" + StringHelper.getLeadingZero (nMinute, LENGTH_MIN) + ":" + StringHelper.getLeadingZero (nSecond, LENGTH_SEC) + "." + nMilliSeconds; return this; }
/** * @return The short transaction key containing only 2 digits (like in 'T10') */ @Nonnull @Nonempty public String getTransactionKeyShort () { return "T" + StringHelper.getLeadingZero (m_nNumber, 2) + m_sSubNumber; }
/** * Creates and returns a {@link File} representing a uniquely named temporary * file in the configured repository path. The lifetime of the file is tied to * the lifetime of the <code>FileItem</code> instance; the file will be * deleted when the instance is garbage collected. * * @return The {@link File} to be used for temporary storage. */ @Nonnull protected File getTempFile () { if (m_aTempFile == null) { // If you manage to get more than 100 million of ids, you'll // start getting ids longer than 8 characters. final String sUniqueID = StringHelper.getLeadingZero (s_aTempFileCounter.getAndIncrement (), 8); final String sTempFileName = "upload_" + UID + "_" + sUniqueID + ".tmp"; m_aTempFile = new File (m_aTempDir, sTempFileName); } return m_aTempFile; }
/** * @return The long transaction key containing 3 digits (like in 'T010') */ @Nonnull @Nonempty public String getTransactionKey () { return "T" + StringHelper.getLeadingZero (m_nNumber, 3) + m_sSubNumber; }
@Nonnull public HCTime setAsTimezone (@CheckForSigned final int nMinutes) { final int nHours = nMinutes / CGlobal.MINUTES_PER_HOUR; final int nRestMinutes = nMinutes % CGlobal.MINUTES_PER_HOUR; m_sDatetime = (nHours < 0 ? "-" : "+") + StringHelper.getLeadingZero (MathHelper.abs (nHours), LENGTH_HOUR) + ":" + StringHelper.getLeadingZero (MathHelper.abs (nRestMinutes), LENGTH_MIN); return this; }
@Nullable public static String getNonceCountString (@CheckForSigned final int nNonceCount) { return nNonceCount <= 0 ? null : StringHelper.getLeadingZero (StringHelper.getHexString (nNonceCount), 8); }
private EBII2Transaction (@Nonnull @Nonempty final String sName, @Nonnegative final int nNumber, @Nullable final String sSubNumber, @Nonnull @Nonempty final String sVersion, @Nonnull final EBII2Group eGroup, @Nonnull final EUBL21DocumentType eUBLDocumentType) { m_sID = name (); m_sName = sName; m_nNumber = nNumber; m_sSubNumber = StringHelper.getNotNull (sSubNumber, ""); m_sVersion = sVersion; m_sTransactionID = "urn:www.cenbii.eu:transaction:biitrns" + StringHelper.getLeadingZero (nNumber, 3) + m_sSubNumber + ":ver" + sVersion; m_eGroup = eGroup; m_eUBLDocumentType = eUBLDocumentType; }
@Nonnull @Nonempty public static String getRelativeAuditDirectory (@Nonnull final LocalDate aDate) { return getRelativeAuditDirectoryYear (aDate.getYear ()) + StringHelper.getLeadingZero (aDate.getMonthValue (), 2) + "/"; }
/** * Set the default storage file provider. In case you played around and want to * restore the default behavior. * * @see #setStorageFileProvider(IFunction) * @since 8.0.3 */ public static void setDefaultStorageFileProvider () { setStorageFileProvider (aMetadata -> { final LocalDateTime aNow = PDTFactory.getCurrentLocalDateTime (); final String sFilename = StringHelper.getConcatenatedOnDemand (PDTIOHelper.getLocalDateTimeForFilename (aNow), "-", aMetadata.getErrorID ()) + ".xml"; return WebFileIO.getDataIO () .getFile ("internal-errors/" + aNow.getYear () + "/" + StringHelper.getLeadingZero (aNow.getMonthValue (), 2) + "/" + sFilename); }); }