Sha256: 29824946ce2b336bbfbaf459de7d5ea6618c7340fca0e08ff9a477a817dd8802
Contents?: true
Size: 925 Bytes
Versions: 29
Compression:
Stored size: 925 Bytes
Contents
package org.embulk.output.jdbc; import java.sql.Timestamp; import java.text.FieldPosition; import java.text.SimpleDateFormat; import java.util.Date; public class TimestampFormat extends SimpleDateFormat { private final int scale; public TimestampFormat(String pattern, int scale) { super(pattern); this.scale = scale; } @Override public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos) { StringBuffer buffer = super.format(date, toAppendTo, pos); if (scale > 0) { buffer.append('.'); String nanos = Integer.toString(((Timestamp)date).getNanos()); int zeros = Math.min(scale, 9 - nanos.length()); for (int i = 0; i < zeros; i++) { buffer.append('0'); } buffer.append(nanos.substring(0, scale - zeros)); } return buffer; } }
Version data entries
29 entries across 29 versions & 2 rubygems