本文整理匯總了Java中java.time.Month.of方法的典型用法代碼示例。如果您正苦於以下問題:Java Month.of方法的具體用法?Java Month.of怎麽用?Java Month.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.Month
的用法示例。
在下文中一共展示了Month.of方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readExternal
import java.time.Month; //導入方法依賴的package包/類
/**
* Reads the state from the stream.
*
* @param in the input stream, not null
* @return the created object, not null
* @throws IOException if an error occurs
*/
static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException {
int data = in.readInt();
Month month = Month.of(data >>> 28);
int dom = ((data & (63 << 22)) >>> 22) - 32;
int dowByte = (data & (7 << 19)) >>> 19;
DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte);
int timeByte = (data & (31 << 14)) >>> 14;
TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12];
int stdByte = (data & (255 << 4)) >>> 4;
int beforeByte = (data & (3 << 2)) >>> 2;
int afterByte = (data & 3);
LocalTime time = (timeByte == 31 ? LocalTime.ofSecondOfDay(in.readInt()) : LocalTime.of(timeByte % 24, 0));
ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900));
ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800));
ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800));
return ZoneOffsetTransitionRule.of(month, dom, dow, time, timeByte == 24, defn, std, before, after);
}
示例2: test_factory_int_singleton
import java.time.Month; //導入方法依賴的package包/類
@Test
public void test_factory_int_singleton() {
for (int i = 1; i <= MAX_LENGTH; i++) {
Month test = Month.of(i);
assertEquals(test.getValue(), i);
}
}
示例3: sortCompressedLogs
import java.time.Month; //導入方法依賴的package包/類
/**
* Sorts compressed logs into a new folder
*
* @param folder The log
* @param logFolder The logFolder name
* @return The result
*/
public static boolean sortCompressedLogs(File folder, String logFolder) {
File[] files = folder.listFiles();
if(files == null) return false;
for(File file : files) {
if(!file.getName().endsWith(".log.gz")) continue;
String fileName = file.getName();
String[] firstSplit = fileName.split("\\.log\\.gz", 2);
fileName = firstSplit[0];
String[] secondSplit = fileName.split("-");
int count = Integer.parseInt(secondSplit[secondSplit.length - 1]);
String fileNameWithoutCount = fileName.replace("-" + count, "");
String[] spl = fileName.split("-");
if(spl.length < 3) continue;
// list the foldername (e.g. October, 2016)
String folderName = "";
try {
int monthId = Integer.parseInt(spl[1]);
int year = Integer.parseInt(spl[2]);
Month month = Month.of(monthId);
folderName = StringUtil.upperFirstLetter(month.name().toLowerCase()) + ", " + year;
}
catch(Exception ex) {
continue;
}
if(folderName.isEmpty()) continue;
// create the folder
File targetFolder = new File(logFolder + "/" + folderName);
int newCount = IOUtil.getNextId(targetFolder, fileNameWithoutCount, "-", ".log.gz", 0);
IOUtil.moveFiles(file, fileNameWithoutCount + "-" + newCount + ".log.gz", targetFolder);
}
return true;
}
示例4: YearViewSkin
import java.time.Month; //導入方法依賴的package包/類
public YearViewSkin(YearView view) {
super(view);
view.dateProperty().addListener(evt -> updateMonths());
GridPane gridPane = new GridPane();
gridPane.getStyleClass().add("container");
gridPane.setMaxSize(MAX_VALUE, MAX_VALUE);
for (int row = 0; row < 3; row++) {
RowConstraints rowConstraints = new RowConstraints();
rowConstraints.setMinHeight(Region.USE_PREF_SIZE);
rowConstraints.setPrefHeight(Region.USE_COMPUTED_SIZE);
rowConstraints.setMaxHeight(Region.USE_COMPUTED_SIZE);
rowConstraints.setVgrow(Priority.ALWAYS);
rowConstraints.setValignment(VPos.CENTER);
gridPane.getRowConstraints().add(rowConstraints);
}
for (int col = 0; col < 4; col++) {
ColumnConstraints colConstraints = new ColumnConstraints();
colConstraints.setMinWidth(Region.USE_PREF_SIZE);
colConstraints.setPrefWidth(Region.USE_COMPUTED_SIZE);
colConstraints.setMaxWidth(Region.USE_COMPUTED_SIZE);
colConstraints.setHgrow(Priority.ALWAYS);
colConstraints.setHalignment(HPos.CENTER);
gridPane.getColumnConstraints().add(colConstraints);
}
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 4; col++) {
Month month = Month.of(row * 4 + col + 1);
YearMonthView yearMonthView = view.getMonthView(month);
yearMonthView.setShowMonthArrows(false);
yearMonthView.setShowTodayButton(false);
yearMonthView.setShowUsageColors(true);
yearMonthView.setClickBehaviour(YearMonthView.ClickBehaviour.SHOW_DETAILS);
gridPane.add(yearMonthView, col, row);
// do not bind date, we manage it manually
view.bind(yearMonthView, false);
}
}
getChildren().add(gridPane);
updateMonths();
}
示例5: test_factory_int_tooLow
import java.time.Month; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_tooLow() {
Month.of(0);
}
示例6: test_factory_int_tooHigh
import java.time.Month; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_tooHigh() {
Month.of(13);
}