本文整理了Java中org.eclipse.persistence.internal.helper.Helper.buildZeroPrefixAndTruncTrailZeros()
方法的一些代码示例,展示了Helper.buildZeroPrefixAndTruncTrailZeros()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Helper.buildZeroPrefixAndTruncTrailZeros()
方法的具体详情如下:
包路径:org.eclipse.persistence.internal.helper.Helper
类名称:Helper
方法名:buildZeroPrefixAndTruncTrailZeros
[英]Build a numerical string with leading 0s and truncate trailing zeros. number is an existing number that the new string will be built on. totalDigits is the number of the required digits of the string.
[中]构建一个前导为0的数字字符串,并截断尾随的零。number是新字符串将基于的现有编号。totalDigits是字符串所需的位数。
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* Convenience method that appends nanosecond values from a given
* time to a given string.
*
* @param string
* @param time
* @return
*/
private String appendNanos(String string, Timestamp ts) {
StringBuilder strBldr = new StringBuilder(string);
int nanos = ts.getNanos();
strBldr.append(nanos==0 ? ".0" : '.' + Helper.buildZeroPrefixAndTruncTrailZeros(nanos, TOTAL_NS_DIGITS)).toString();
return strBldr.toString();
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* Convenience method that appends nanosecond values from a given
* time to a given string.
*
* @param string
* @param time
* @return
*/
private String appendNanos(String string, Timestamp ts) {
StringBuilder strBldr = new StringBuilder(string);
int nanos = ts.getNanos();
strBldr.append(nanos==0 ? "" : '.' + Helper.buildZeroPrefixAndTruncTrailZeros(nanos, TOTAL_NS_DIGITS)).toString();
return strBldr.toString();
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Convenience method that appends nanosecond values from a given
* time to a given string.
*
* @param string
* @param time
* @return
*/
private String appendNanos(String string, Timestamp ts) {
StringBuilder strBldr = new StringBuilder(string);
int nanos = ts.getNanos();
strBldr.append(nanos==0 ? "" : '.' + Helper.buildZeroPrefixAndTruncTrailZeros(nanos, TOTAL_NS_DIGITS)).toString();
return strBldr.toString();
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* Convenience method that appends millisecond values from a given
* time to a given string.
*
* @param string
* @param time
* @return
*/
private String appendMillis(String string, long time) {
StringBuilder strBldr = new StringBuilder(string);
int msns = (int) (time % 1000);
if (msns < 0) {
// adjust for negative time values, i.e. before Epoch
msns = msns + 1000;
}
strBldr.append(msns==0 ? ".0" : '.' + Helper.buildZeroPrefixAndTruncTrailZeros(msns, TOTAL_MS_DIGITS)).toString();
return strBldr.toString();
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Convenience method that appends millisecond values from a given
* time to a given string.
*
* @param string
* @param time
* @return
*/
private String appendMillis(String string, long time) {
StringBuilder strBldr = new StringBuilder(string);
int msns = (int) (time % 1000);
if (msns < 0) {
// adjust for negative time values, i.e. before Epoch
msns = msns + 1000;
}
strBldr.append(msns==0 ? "" : '.' + Helper.buildZeroPrefixAndTruncTrailZeros(msns, TOTAL_MS_DIGITS)).toString();
return strBldr.toString();
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* Convenience method that appends millisecond values from a given
* time to a given string.
*
* @param string
* @param time
* @return
*/
private String appendMillis(String string, long time) {
StringBuilder strBldr = new StringBuilder(string);
int msns = (int) (time % 1000);
if (msns < 0) {
// adjust for negative time values, i.e. before Epoch
msns = msns + 1000;
}
strBldr.append(msns==0 ? "" : '.' + Helper.buildZeroPrefixAndTruncTrailZeros(msns, TOTAL_MS_DIGITS)).toString();
return strBldr.toString();
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Print the Calendar.
* Normally the calendar must be printed in the local time, but if the timezone is printed,
* it must be printing in its timezone.
*/
public static String printCalendar(Calendar calendar, boolean useLocalTime) {
String millisString;
// String zeros = "000000000";
if (calendar.get(Calendar.MILLISECOND) == 0) {
millisString = "0";
} else {
millisString = buildZeroPrefixAndTruncTrailZeros(calendar.get(Calendar.MILLISECOND), 3);
}
StringBuilder timestampBuf = new StringBuilder();
timestampBuf.append(printDate(calendar, useLocalTime));
timestampBuf.append(" ");
timestampBuf.append(printTime(calendar, useLocalTime));
timestampBuf.append(".");
timestampBuf.append(millisString);
return timestampBuf.toString();
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* Print the Calendar.
* Normally the calendar must be printed in the local time, but if the timezone is printed,
* it must be printing in its timezone.
*/
public static String printCalendar(Calendar calendar, boolean useLocalTime) {
String millisString;
// String zeros = "000000000";
if (calendar.get(Calendar.MILLISECOND) == 0) {
millisString = "0";
} else {
millisString = buildZeroPrefixAndTruncTrailZeros(calendar.get(Calendar.MILLISECOND), 3);
}
StringBuffer timestampBuf = new StringBuffer();
timestampBuf.append(printDate(calendar, useLocalTime));
timestampBuf.append(" ");
timestampBuf.append(printTime(calendar, useLocalTime));
timestampBuf.append(".");
timestampBuf.append(millisString);
return timestampBuf.toString();
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* Print the Calendar.
* Normally the calendar must be printed in the local time, but if the timezone is printed,
* it must be printing in its timezone.
*/
public static String printCalendar(Calendar calendar, boolean useLocalTime) {
String millisString;
// String zeros = "000000000";
if (calendar.get(Calendar.MILLISECOND) == 0) {
millisString = "0";
} else {
millisString = buildZeroPrefixAndTruncTrailZeros(calendar.get(Calendar.MILLISECOND), 3);
}
StringBuilder timestampBuf = new StringBuilder();
timestampBuf.append(printDate(calendar, useLocalTime));
timestampBuf.append(" ");
timestampBuf.append(printTime(calendar, useLocalTime));
timestampBuf.append(".");
timestampBuf.append(millisString);
return timestampBuf.toString();
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* Print the sql.Timestamp.
*/
public static String printTimestamp(java.sql.Timestamp timestamp) {
// PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
Calendar calendar = allocateCalendar();
calendar.setTime(timestamp);
String nanosString;
if (timestamp.getNanos() == 0) {
nanosString = "0";
} else {
nanosString = buildZeroPrefixAndTruncTrailZeros(timestamp.getNanos(), 9);
}
StringBuilder timestampBuf = new StringBuilder();
timestampBuf.append(printDate(calendar));
timestampBuf.append(" ");
timestampBuf.append(printTime(calendar));
timestampBuf.append(".");
timestampBuf.append(nanosString);
releaseCalendar(calendar);
return (timestampBuf.toString());
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* Print the sql.Timestamp.
*/
public static String printTimestamp(java.sql.Timestamp timestamp) {
// PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
Calendar calendar = allocateCalendar();
calendar.setTime(timestamp);
String nanosString;
if (timestamp.getNanos() == 0) {
nanosString = "0";
} else {
nanosString = buildZeroPrefixAndTruncTrailZeros(timestamp.getNanos(), 9);
}
StringBuilder timestampBuf = new StringBuilder();
timestampBuf.append(printDate(calendar));
timestampBuf.append(" ");
timestampBuf.append(printTime(calendar));
timestampBuf.append(".");
timestampBuf.append(nanosString);
releaseCalendar(calendar);
return (timestampBuf.toString());
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* Print the sql.Timestamp.
*/
public static String printTimestamp(java.sql.Timestamp timestamp) {
// PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
Calendar calendar = allocateCalendar();
calendar.setTime(timestamp);
String nanosString;
if (timestamp.getNanos() == 0) {
nanosString = "0";
} else {
nanosString = buildZeroPrefixAndTruncTrailZeros(timestamp.getNanos(), 9);
}
StringBuffer timestampBuf = new StringBuffer();
timestampBuf.append(printDate(calendar));
timestampBuf.append(" ");
timestampBuf.append(printTime(calendar));
timestampBuf.append(".");
timestampBuf.append(nanosString);
releaseCalendar(calendar);
return (timestampBuf.toString());
}
内容来源于网络,如有侵权,请联系作者删除!